Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
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. |
jreback
added Bug Reshaping
labels
Jun 7, 2015
jreback
added this to the
Next Major Release
milestone
Jun 7, 2015
|
So this is not a bug? should we:
|
|
return an empty frame |
dan7davis
commented
Jan 5, 2016
|
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:
|
dan7davis
commented
Jan 5, 2016
|
@jreback problem solved. thank you! really appreciate the alacrity |
|
want to do a pull request to fix in master? |
dan7davis
commented
Jan 6, 2016
|
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 notifications@github.com
|
|
contributing is a great way to learn ...., see our docs: http://pandas.pydata.org/pandas-docs/stable/contributing.html any questions, pls ask. |
songhuiming commentedJun 5, 2015
get ~~ KeyError: 'dummy' ~~ when I run the following: