Skip to content

groupby with as_index=False, inconsistency between max and idxmax #8582

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
behzadnouri opened this issue Oct 19, 2014 · 0 comments · Fixed by #8585
Closed

groupby with as_index=False, inconsistency between max and idxmax #8582

behzadnouri opened this issue Oct 19, 2014 · 0 comments · Fixed by #8585
Milestone

Comments

@behzadnouri
Copy link
Contributor

>>> df = pd.DataFrame(np.random.randint(0, 100, (50, 2)), columns=['jim', 'joe'])
>>> ts = pd.Series(np.random.randint(0, 3, 50))
>>> df.groupby(ts, as_index=False).idxmax()
   jim  joe
0   25   36
1   22    5
2    3    4
>>> df.groupby(ts, as_index=False).max()
   NaN  jim  joe
0    0   93   94
1    1   94   89
2    2   85   93

max adds the grouper to the result frame, whereas idxmax doesn't.

The API documentation says:

as_index=False is effectively “SQL-style” grouped output

so i would assume, it should not inject a new column with NaN name.

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

Successfully merging a pull request may close this issue.

2 participants