apache / apache/beam

DataFrame API: groupby(dropna=False) still drops NAs when grouping on multiple columns or indexes

Open
#21,014 0 comments 0 reactions 0 assignees View on GitHub
bug core dataframe P3 python
Dominant language
Java
Stars
8.7k
Forks
4.7k
Avg merge
1d 20h
Merged PRs (30d)
196

Description

```

df.groupby(['foo', 'bar'], dropna=False).sum()

```

This will still drop NAs in the output.

This is due to pandas bug [36470](https://github.com/pandas-dev/pandas/issues/36470) "BUG: groupby(..., dropna=False) excludes NA values when grouping on MultiIndex levels".

We implement groupby by moving all grouped data into the index and requiring Index() partitioning, so we will always run into this issue, even when the user is grouping on columns, not indexes.

Imported from Jira [BEAM-12495](https://issues.apache.org/jira/browse/BEAM-12495). Original Jira may contain additional context.
Reported by: bhulette.

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.