Better error message for DataFrame.hist() without numerical columns (…
State: closed

Closes #10444

Added simple check for non-zero number of numeric columns plus suggested error message in case the check fails. 

Happy to make any adjustments this if desired.


Labels:
name: Visualization
description: plotting
name: Dtype Conversions
description: Unexpected or buggy dtype conversions
name: Error Reporting
description: Incorrect or improved errors from pandas

Comments:
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26483?src=pr&el=h1) Report
> Merging [#26483](https://codecov.io/gh/pandas-dev/pandas/pull/26483?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/d3a19121790a517c03755fc01f74ab149d9c77f5?src=pr&el=desc) will **decrease** coverage by `0.01%`.
> The diff coverage is `0%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/26483/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/26483?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #26483      +/-   ##
==========================================
- Coverage   91.75%   91.74%   -0.02%     
==========================================
  Files         174      174              
  Lines       50756    50758       +2     
==========================================
- Hits        46572    46568       -4     
- Misses       4184     4190       +6
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.25% <0%> (-0.01%)` | :arrow_down: |
| #single | `41.69% <0%> (-0.09%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/26483?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/plotting/\_core.py](https://codecov.io/gh/pandas-dev/pandas/pull/26483/diff?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19jb3JlLnB5) | `83.77% <0%> (-0.13%)` | :arrow_down: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/26483/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `78.94% <0%> (-10.53%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/26483/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.02% <0%> (-0.12%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26483?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26483?src=pr&el=footer). Last update [d3a1912...576f0a8](https://codecov.io/gh/pandas-dev/pandas/pull/26483?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26483?src=pr&el=h1) Report
> Merging [#26483](https://codecov.io/gh/pandas-dev/pandas/pull/26483?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/d3a19121790a517c03755fc01f74ab149d9c77f5?src=pr&el=desc) will **decrease** coverage by `0.01%`.
> The diff coverage is `0%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/26483/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/26483?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #26483      +/-   ##
==========================================
- Coverage   91.75%   91.74%   -0.02%     
==========================================
  Files         174      174              
  Lines       50756    50763       +7     
==========================================
- Hits        46572    46570       -2     
- Misses       4184     4193       +9
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.25% <0%> (-0.01%)` | :arrow_down: |
| #single | `41.69% <0%> (-0.09%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/26483?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/plotting/\_core.py](https://codecov.io/gh/pandas-dev/pandas/pull/26483/diff?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19jb3JlLnB5) | `83.77% <0%> (-0.13%)` | :arrow_down: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/26483/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `78.94% <0%> (-10.53%)` | :arrow_down: |
| [pandas/core/dtypes/common.py](https://codecov.io/gh/pandas-dev/pandas/pull/26483/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2NvbW1vbi5weQ==) | `95.85% <0%> (-1.6%)` | :arrow_down: |
| [pandas/core/indexes/timedeltas.py](https://codecov.io/gh/pandas-dev/pandas/pull/26483/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy90aW1lZGVsdGFzLnB5) | `90.96% <0%> (-0.63%)` | :arrow_down: |
| [pandas/core/indexes/datetimes.py](https://codecov.io/gh/pandas-dev/pandas/pull/26483/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9kYXRldGltZXMucHk=) | `96.36% <0%> (-0.5%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/26483/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.02% <0%> (-0.12%)` | :arrow_down: |
| [pandas/core/indexes/range.py](https://codecov.io/gh/pandas-dev/pandas/pull/26483/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9yYW5nZS5weQ==) | `97.97% <0%> (-0.01%)` | :arrow_down: |
| [pandas/core/indexes/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/26483/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9iYXNlLnB5) | `96.73% <0%> (ø)` | :arrow_up: |
| [pandas/core/indexes/numeric.py](https://codecov.io/gh/pandas-dev/pandas/pull/26483/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9udW1lcmljLnB5) | `97.34% <0%> (+0.03%)` | :arrow_up: |
| [pandas/core/indexes/period.py](https://codecov.io/gh/pandas-dev/pandas/pull/26483/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9wZXJpb2QucHk=) | `92.58% <0%> (+0.47%)` | :arrow_up: |
| ... and [1 more](https://codecov.io/gh/pandas-dev/pandas/pull/26483/diff?src=pr&el=tree-more) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26483?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26483?src=pr&el=footer). Last update [d3a1912...91ab6d8](https://codecov.io/gh/pandas-dev/pandas/pull/26483?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

@matsmaiwald 

thanks for the PR.

the CI failure looks unrelated to your change.

can you add a test, perhaps using the code sample in the issue as the test case?
Thanks for the code review @simonjayhawkins.

I just added a test in the way you suggested.
lgtm @datapythonista @TomAugspurger 
lgtm, not sure about marking the test as slow, is it really slow?

Also, if this can wait until #26414 that would make my life a bit easier (will be much easier to resolve the conflict here than there).
> lgtm, not sure about marking the test as slow, is it really slow?

that had crossed my mind, but all the tests in this module are marked as slow, so was thinking that it would be better to mark as slow at the module level as a follow-up at some point.
thanks @matsmaiwald