-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
KeyError: '__dummy__' for pd.crosstab in pandas #10291
Comments
Even simpler example. Perhaps something to do with the indices not overlapping at all.
|
Believe this is the root cause of things: http://pandas.pydata.org/pandas-docs/stable/groupby.html#na-group-handling |
Yes http://pandas.pydata.org/pandas-docs/stable/groupby.html#na-group-handling is this cause. Because the 2 indices have no overlapping indexes, this means that each groupby ends up including a nan which then excludes it from groupby result. You then end up with an empty dataframe and that is the cause of the KeyError, as you're accessing df['dummy'] on an empty dataframe. |
yeh, this should just be an empty frame, as there are no cross-tabulations. |
So this is not a bug? should we:
|
return an empty frame |
I'm getting the same KeyError: 'dummy' for my grouped data. And I'm not really sure how to fix it / what you mean by 'return an empty frame.' Care to dumb it down/show precisely what you mean? Thanks! |
@dan7davis this needs a fix that would return an empty frame when catching the https://github.com/pydata/pandas/blob/master/pandas/tools/pivot.py#L151, just need something like:
|
@jreback problem solved. thank you! really appreciate the alacrity |
want to do a pull request to fix in master? |
I'm (very) new to coding/python/GitHub, so unfortunately I have no idea On Tue, Jan 5, 2016 at 3:32 PM, Jeff Reback [email protected]
|
contributing is a great way to learn ...., see our docs: http://pandas.pydata.org/pandas-docs/stable/contributing.html any questions, pls ask. |
get ~~ KeyError: 'dummy' ~~ when I run the following:
The text was updated successfully, but these errors were encountered: