groupby with as_index=False, inconsistency between max and idxmax · Issue #8582 · pandas-dev/pandas (original) (raw)

>>> 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.