-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Since 0.13: passing pandas DataFrame/Series like numpy array breaks #6127
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
what numpy/matplotlib are you using here? |
it could be something like this: http://pandas.pydata.org/pandas-docs/dev/whatsnew.html#internal-refactoring |
I think your df has float headers which maybe the problem
|
This does happen with a df that was read in via a csv that had proper columns; i.e. the error does not occur only when I load from the file I provided. http://pandas.pydata.org/pandas-docs/dev/whatsnew.html#internal-refactoring reads as if it could be the cause but I'm obviously not familiar enough with the internals. I only observed this when I slice a dataframe and select a column inside a
|
can you try on master, ? |
So far couldn't reproduce on master! |
I'll close this and will reopen if problem resurfaces. |
ok...gr8! |
ok, resurfaced. Here is an updated file: https://gist.github.com/anonymous/8676957 I can trigger this by loading and passing this (loaded as |
can u put up the exact code u r using to load |
Hrm, I can't reproduce with the freshly loaded one, sorry... I guess I could pickle it but not sure how to upload that anywhere quick and easy. |
Dropbox public link |
any reason you dont use |
@twiecki can you repro? about to release 0.13.1 |
Sorry, here's the pickle that can reproduce it: df = pd.read_pickle('/tmp/anti_val.pickle')
hist(df.ix[df.cond == 'incong', 'rt']);
|
ok, this will reproduce it:
Here's what is happening. Matplotlib thinks it is always passed an ndarray, or an iterable, so it first If you have a 0th element that all is good. Matplotlib should be trapping this exception , so I believe this is a trivial bug there. work-arounds:
IIRC matplotlib < 1.3 doesn't have this issue. |
Hm, OK. I always thought it was a nice feature that a pandas df behaved like a ndarray. And I think this happened not only with hist(). Isn't there some way to fake the |
I have tried that, but its essentially a c-level call, not even with a MetaClass. blame it on matplotlib!!! maybe file a bug report! |
I see. Well maybe it's better to explicit in any case; I've just gotten used to passing it around like a ndarray. Agreed that it's a |
This commit prevents the KeyError raised when DataFrame.plot() is called with xerr or yerr being a Series or DataFrame whose index doesn't include 0. The error comes from matplotlib code which tries to access xerr[0] or yerr[0], so to solve the problem, we convert xerr and yerr from Pandas objects to NumPy ndarrays before sending them through to matplotlib. This is a different instance of the same type of problem in Github issues pandas-dev#4493 and pandas-dev#6127 (and perhaps others).
As discussed in #6063:
I noticed that that numpy-style access breaks sometimes under 0.13. While I haven't been able to pin-point the issue, calls like
pylab.hist(-df.ix[row, col_name])
fail with somex[0]
index error and I have to usepylab.hist(-df.ix[row, col_name]).values
.Here is a csv file for which this happens: https://gist.github.com/8651509
produces:
While passing
.values
works.The text was updated successfully, but these errors were encountered: