Skip to content

[BUG] Grouped-by column loses name when empty list of aggregations is specified. #32580

Closed
echozzy629/pandas_CPTS581
#3
@shwina

Description

@shwina
In [53]: a = pd.DataFrame({'a': [1, 1, 2], 'b': [1, 2, 3], 'c': [1, 2, 4]})

In [54]: a.groupby('a').agg({'c': ['min']}) # name preserved in index
Out[54]:
    c
  min
a
1   1
2   4

In [55]: a.groupby('a').agg({'b': [], 'c': ['min']}) # name lost in index
Out[55]:
    c
  min
1   1
2   4

In the above snippet, the name of the grouped by column ('a') is preserved in the former case, and lost in the latter case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions