-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Better error message when using DataFrame.hist() without numerical columns #10444
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
Comments
We (only?) plot numeric types ( What's you use here that you're getting object dtypes? Integer NaNs? You'll typically want to avoid object dtypes since they're much slower for numeric operations. |
I agree with what you're saying, and I think a suitable fix would include a more explicit check for the dtypes and show an error. As it is, I spent some time trying to figure out what the issue was, especially because the string representation of the DataFrame doesn't show the dtypes. I am using floats and integers, but by accident, when I constructed the DataFrame, all entries were NaN objects, and then I populated the DataFrame in a loop. |
An error message like |
Any progress on this? It took me quite a few hours to realize it was a dtype error. |
Still open. Interested in submitting a PR to fix it?
…On Tue, Aug 21, 2018 at 10:06 AM zhanwenchen ***@***.***> wrote:
Any progress on this? It took me quite a few hours to realize it was a
dtype error.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#10444 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABQHIrdc3hje4W1xv92Y3_uxXpg7nC0Rks5uTCHbgaJpZM4FMPtc>
.
|
@TomAugspurger i get a nonsense error here from a dataframe with 2 columns, but not when histogramming them one at a time as a series:
traceback:
colab notebook: INSTALLED VERSIONScommit: None pandas: 0.22.0 |
@denfromufa do you want to fix it? Here you have the general documentation on how to do it: https://pandas.pydata.org/pandas-docs/stable/contributing.html The fix should be easy, just checking the type and raising an exception with a useful message. |
@datapythonista i don't agree on this solution - it should just work. why raise an exception when histogram works for each series? however i did not have a chance to debug this yet. |
if you make it work even better, feel free to send a PR for it. |
I am struggling with a similar issue. I am building data frames from various sources, each with 2690 rows; from one source I can get the histogram to work, from the other I get the error reported above (and below). My plan was to convert both data frames to a dict using df.to_dict() and back to a data frame using pd.DataFrame.from_dict(), to explore more and reproduce the issue here in case someone could point out what the problem was. But when I do that, they both plot just fine. E.g.
When I try to examine the original data frames for NaNs, etc, I cannot tell a difference. Any idea why converting my dfs to dict and back solves this issue? df0:
df1:
ValueError Traceback (most recent call last) C:\conda3x64\envs\p3x64\lib\site-packages\pandas\plotting_core.py in hist_frame(data, column, by, grid, xlabelsize, xrot, ylabelsize, yrot, ax, sharex, sharey, figsize, layout, bins, **kwds) C:\conda3x64\envs\p3x64\lib\site-packages\pandas\plotting_tools.py in _subplots(naxes, sharex, sharey, squeeze, subplot_kw, ax, layout, layout_type, **fig_kw) C:\conda3x64\envs\p3x64\lib\site-packages\matplotlib\figure.py in add_subplot(self, *args, **kwargs) C:\conda3x64\envs\p3x64\lib\site-packages\matplotlib\axes_subplots.py in init(self, fig, args, **kwargs) ValueError: num must be 1 <= num <= 0, not 1 |
Anyone working on this? If not, I'd like to take this up as my first issue. |
all yours @matsmaiwald, thanks |
pandas version: 0.16.2
matplotlib version 1.4.3 (and produced different error message on older version)
The text was updated successfully, but these errors were encountered: