Skip to content

DOC: DataFrame.groupy.agg with a list of tuples #18220

Closed
@tdpetrou

Description

@tdpetrou

Code Sample, a copy-pastable example if possible

>>> df = pd.DataFrame({'key' : ['a', 'a', 'b', 'b', 'a'],
                       'data' : np.random.randn(5)})

>>> df.groupby('key')['data'].agg([('foo', 'mean')])
          foo
key          
a   -0.944872
b    0.893212

Problem description

I know its deprecated to rename columns with a dictionary of dictionaries in a groupby but a list of tuples also renames columns.

This behavior is not found in the docs. I accidentally discovered this a while back and then saw it again in Python for Data Analysis.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions