apache / apache/beam

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

Open
#20,630 0 comments 0 reactions 0 assignees View on GitHub
bug core P3 python
Dominant language
Java
Stars
8.7k
Forks
4.7k
Avg merge
1d 20h
Merged PRs (30d)
196

Description

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: https://github.com/apache/beam/blob/cdb882d9ae554556156bff4843f18567b214df13/sdks/python/apache_beam/dataframe/frames.py#L156

Imported from Jira [BEAM-11305](https://issues.apache.org/jira/browse/BEAM-11305). Original Jira may contain additional context.
Reported by: bhulette.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.