NVIDIA / NVIDIA/cudf

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

Open
#12,411 0 comments 0 reactions 0 assignees View on GitHub
feature request Python
Dominant language
C++
Stars
9.8k
Forks
1.1k
Avg merge
3d 6m
Merged PRs (30d)
278

Description

**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 "", line 1, in
File ".../python3.8/contextlib.py", line 75, in inner
return func(*args, **kwds)
TypeError: agg() got an unexpected keyword argument 'min_height'
```

references:
- https://github.com/pandas-dev/pandas/pull/26399
- https://pandas.pydata.org/pandas-docs/stable/whatsnew/v0.20.0.html#deprecate-groupby-agg-with-a-dictionary-when-renaming

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.