NVIDIA / NVIDIA/cudf

[BUG] Aggregation with NaN not matching Pandas behavior

Open
#9,575 4 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

Aggregation(mean/sum) on cols NaN result in NaN value. even with dropna as `True`

```
>>> df = cudf.DataFrame()
>>> df['a'] = [1,2,3,0,4]
>>> df['b'] = [1,1,1,0,1]
>>> df['c'] = df.a/df.b
>>> df['s'] = 0
>>> df
a b c s
0 1 1 1.0 0
1 2 1 2.0 0
2 3 1 3.0 0
3 0 0 NaN 0
4 4 1 4.0 0
>>> df[['c', 's']].groupby(['s']).mean()
c
s
0 NaN
```

**Expected/Pandas behavior**
```
>>> import pandas as pd
>>> df = pd.DataFrame()
>>> df['a'] = [1,2,3,0,4]
>>> df['b'] = [1,1,1,0,1]
>>> df['c'] = df.a/df.b
>>> df['s'] = 0
>>> df
a b c s
0 1 1 1.0 0
1 2 1 2.0 0
2 3 1 3.0 0
3 0 0 NaN 0
4 4 1 4.0 0
>>> df[['c', 's']].groupby(['s']).mean()
c
s
0 2.5
```

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.