Skip to content

BUG: groupby with reducer of max and as_index=False raises #7115

Closed
@jreback

Description

@jreback

This shouldn't raise

from here originally (not the bug, the data/question):
http://stackoverflow.com/questions/23635647/how-to-force-pandas-dataframe-apply-on-a-grouped-dataframe

In [30]: df = pd.DataFrame({'a':range(5), 'b': range(5, 10)})

In [31]: df
Out[31]: 
   a  b
0  0  5
1  1  6
2  2  7
3  3  8
4  4  9

[5 rows x 2 columns]

In [32]: df.groupby(df.a<2).max()
Out[32]: 
       a  b
a          
False  4  9
True   1  6

[2 rows x 2 columns]

In [33]: df.groupby(df.a<2,as_index=False).max()
ValueError: cannot insert a, already exists

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions