Skip to content

Better error message for DataFrame.hist() without numerical columns (… #26483

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 24, 2019

Conversation

matsmaiwald
Copy link
Contributor

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.

@@ -2426,6 +2426,10 @@ def hist_frame(data, column=None, by=None, grid=True, xlabelsize=None,
data = data._get_numeric_data()
naxes = len(data.columns)

if naxes == 0:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if naxes == 0:
if not naxes:

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer how it is. This is more explicit.

@codecov
Copy link

codecov bot commented May 21, 2019

Codecov Report

Merging #26483 into master will decrease coverage by 0.01%.
The diff coverage is 0%.

Impacted file tree graph

@@            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%) ⬇️
#single 41.69% <0%> (-0.09%) ⬇️
Impacted Files Coverage Δ
pandas/plotting/_core.py 83.77% <0%> (-0.13%) ⬇️
pandas/io/gbq.py 78.94% <0%> (-10.53%) ⬇️
pandas/core/frame.py 97.02% <0%> (-0.12%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d3a1912...576f0a8. Read the comment docs.

@codecov
Copy link

codecov bot commented May 21, 2019

Codecov Report

Merging #26483 into master will decrease coverage by 0.01%.
The diff coverage is 0%.

Impacted file tree graph

@@            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%) ⬇️
#single 41.69% <0%> (-0.09%) ⬇️
Impacted Files Coverage Δ
pandas/plotting/_core.py 83.77% <0%> (-0.13%) ⬇️
pandas/io/gbq.py 78.94% <0%> (-10.53%) ⬇️
pandas/core/dtypes/common.py 95.85% <0%> (-1.6%) ⬇️
pandas/core/indexes/timedeltas.py 90.96% <0%> (-0.63%) ⬇️
pandas/core/indexes/datetimes.py 96.36% <0%> (-0.5%) ⬇️
pandas/core/frame.py 97.02% <0%> (-0.12%) ⬇️
pandas/core/indexes/range.py 97.97% <0%> (-0.01%) ⬇️
pandas/core/indexes/base.py 96.73% <0%> (ø) ⬆️
pandas/core/indexes/numeric.py 97.34% <0%> (+0.03%) ⬆️
pandas/core/indexes/period.py 92.58% <0%> (+0.47%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d3a1912...91ab6d8. Read the comment docs.

@simonjayhawkins
Copy link
Member

@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?

@matsmaiwald
Copy link
Contributor Author

Thanks for the code review @simonjayhawkins.

I just added a test in the way you suggested.

@simonjayhawkins
Copy link
Member

lgtm @datapythonista @TomAugspurger

@gfyoung gfyoung added Dtype Conversions Unexpected or buggy dtype conversions Error Reporting Incorrect or improved errors from pandas Visualization plotting labels May 21, 2019
@datapythonista
Copy link
Member

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).

@simonjayhawkins
Copy link
Member

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.

@jreback jreback added this to the 0.25.0 milestone May 24, 2019
@jreback jreback merged commit a439f45 into pandas-dev:master May 24, 2019
@jreback
Copy link
Contributor

jreback commented May 24, 2019

thanks @matsmaiwald

@matsmaiwald matsmaiwald deleted the better_error_message branch May 25, 2019 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dtype Conversions Unexpected or buggy dtype conversions Error Reporting Incorrect or improved errors from pandas Visualization plotting
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Better error message when using DataFrame.hist() without numerical columns
5 participants