Skip to content

Don't fail when plotting Series/DataFrame with no row #28226

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 1 commit into from
Sep 11, 2019

Conversation

randomstuff
Copy link
Contributor

@randomstuff randomstuff commented Aug 29, 2019

When Series or DataFrames was empty (no cells) after removing columns
without a suitable type (.select_dtypes), pandas was throwing a "no
numeric data to plot" exception.

This can happen:

  1. either because there is no column with a suitable type;

  2. or if there is no row.

Raising an exception in the first case makes sense but we should
probably avoid throwing an exception in the second case.

@WillAyd
Copy link
Member

WillAyd commented Aug 30, 2019

Can you add a test for this?

@pep8speaks
Copy link

pep8speaks commented Aug 30, 2019

Hello @randomstuff! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2019-08-30 21:04:52 UTC

@randomstuff
Copy link
Contributor Author

Yes, I was actually wondering how I should properly test this (and how the plot tests are done). I have added very basic tests.

Copy link
Contributor

@TomAugspurger TomAugspurger left a comment

Choose a reason for hiding this comment

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

Thanks. Needs a release note in 1.0.0.rst.

@TomAugspurger TomAugspurger added this to the 1.0 milestone Aug 30, 2019
@randomstuff randomstuff force-pushed the empty_plot branch 4 times, most recently from 9dbf7dc to 4384514 Compare August 30, 2019 20:55
When Series or DataFrames was empty (no cells) after removing columns
without a suitable type (.select_dtypes), pandas was throwing a "no
numeric data to plot" exception.

This can happen:

1) either because there is no column with a suitable type;

2) or if there is no row.

Raising an exception in the first case makes sense but we should
probably avoid throwing an exception in the second case.
Copy link
Member

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

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

@TomAugspurger TomAugspurger merged commit 261c3a6 into pandas-dev:master Sep 11, 2019
@TomAugspurger
Copy link
Contributor

Thanks @randomstuff!

@randomstuff randomstuff deleted the empty_plot branch April 29, 2020 23:16
@markobogoevski
Copy link

Which exact pandas version was this added in?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot plot empty Series
6 participants