Skip to content

[FEA] groupby.agg() support for controlling output columns #12411

@mattf

Description

@mattf

Is your feature request related to a problem? Please describe.
rewriting code with import cudf as pd

Describe the solution you'd like

>>> import cudf as pd
>>> pd.__version__
'22.12.01'

>>> df = pd.DataFrame({'kind': ['cat', 'dog', 'cat', 'dog'], 'height': [9.1, 6.0, 9.5, 34.0], 'weight': [7.9, 7.5, 9.9, 198.0]})
>>> df
  kind  height  weight
0  cat     9.1     7.9
1  dog     6.0     7.5
2  cat     9.5     9.9
3  dog    34.0   198.0

>>> df.to_pandas().groupby('kind').agg(min_height=('height', 'min'), max_weight=('weight', 'max'))
      min_height  max_weight
kind                        
cat          9.1         9.9
dog          6.0       198.0

>>> df.groupby('kind').agg(min_height=('height', 'min'), max_weight=('weight', 'max'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../python3.8/contextlib.py", line 75, in inner
    return func(*args, **kwds)
TypeError: agg() got an unexpected keyword argument 'min_height'

references:

Metadata

Metadata

Assignees

No one assigned

    Labels

    PythonAffects Python cuDF API.feature requestNew feature or request

    Type

    No type

    Projects

    Status

    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions