NVIDIA / NVIDIA/cudf

[BUG] cannot pass numpy funcs to groupby().agg()

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

Description

**Describe the bug**
converting code with `import cudf as pd`

**Steps/Code to reproduce bug**
```
>>> import cudf as pd
>>> pd.__version__
'22.12.01'
>>> df = pd.DataFrame({'a': [1,2,3]*10})

>>> df.to_pandas().groupby('a').agg({'a': np.sum})
a
a
1 10
2 20
3 30

>>> df.groupby('a').agg({'a': np.sum})
Traceback (most recent call last):
File "", line 1, in
File ".../python3.8/contextlib.py", line 75, in inner
return func(*args, **kwds)
File ".../python3.8/site-packages/cudf/core/groupby/groupby.py", line 460, in agg
) = self._groupby.aggregate(columns, normalized_aggs)
File "groupby.pyx", line 309, in cudf._lib.groupby.GroupBy.aggregate
File "groupby.pyx", line 184, in cudf._lib.groupby.GroupBy.aggregate_internal
File "aggregation.pyx", line 866, in cudf._lib.aggregation.make_groupby_aggregation
File "<__array_function__ internals>", line 180, in sum
File ".../python3.8/site-packages/numpy/core/fromnumeric.py", line 2298, in sum
return _wrapreduction(a, np.add, 'sum', axis, dtype, out, keepdims=keepdims,
File ".../python3.8/site-packages/numpy/core/fromnumeric.py", line 84, in _wrapreduction
return reduction(axis=axis, out=out, **passkwargs)
TypeError: sum() got an unexpected keyword argument 'out'
```

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.