Skip to content

Unexpected behavior with groupby on single-row dataframe? #11741

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

Closed
dwyatte opened this issue Dec 2, 2015 · 3 comments
Closed

Unexpected behavior with groupby on single-row dataframe? #11741

dwyatte opened this issue Dec 2, 2015 · 3 comments
Milestone

Comments

@dwyatte
Copy link

dwyatte commented Dec 2, 2015

Do single-row dataframes (not series) get special treatment in some way? It seems you can do arbitrary groupby operations on them on non-existent columns without errors.

df1 = pd.DataFrame(np.random.randn(1,4), columns=list('ABCD'))
df2 = pd.DataFrame(np.random.randn(2,4), columns=list('ABCD'))

In [3]: df1.groupby('asdf')
Out[3]: pandas.core.groupby.DataFrameGroupBy object at 0x1139acb10

In [4]: df2.groupby('asdf')
KeyError: 'asdf'
@nbonnotte
Copy link
Contributor

Yeah, there is a problem. I discovered that while working on issue #11640

I've a PR ready

@nbonnotte
Copy link
Contributor

Solved with PR #12063

@jreback jreback added this to the 0.18.0 milestone Jan 16, 2016
@jreback jreback added the Bug label Jan 16, 2016
@dwyatte
Copy link
Author

dwyatte commented Jan 19, 2016

Great, thanks!

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

No branches or pull requests

3 participants