Skip to content

df.groupby(df.group) produces duplicate column for some aggregation functons #20630

@damccorm

Description

@damccorm

It should be possible to use df.groupby(df.group) or df.groupby('group') and get the same result. Unfortunately for some aggregation functions (max, min, all, any), the former produces an output with an extraneous 'group' column. Note this doesn't happen for some functions, like size.

In groupby, we should check if the the series is one of this dataframe's columns when setting the index:

return df.set_index(by)

Imported from Jira BEAM-11305. Original Jira may contain additional context.
Reported by: bhulette.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions