Skip to content

df.groupby(by=["b"], dropna=False).sum() returns"groupby() got an unexpected keyword argument 'dropna'" #37323

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
vahanm01 opened this issue Oct 21, 2020 · 6 comments
Labels
Bug Groupby Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate

Comments

@vahanm01
Copy link

Using the official documentation for groupby: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.groupby.html

the dropna=False argument does not work even with given example.

l = [[1, 2, 3], [1, None, 4], [2, 1, 3], [1, 2, 2]]
df = pd.DataFrame(l, columns=["a", "b", "c"])
df.groupby(by=["b"], dropna=False).sum()

@arw2019
Copy link
Member

arw2019 commented Oct 21, 2020

This runs on master:

In [2]: l = [[1, 2, 3], [1, None, 4], [2, 1, 3], [1, 2, 2]] 
   ...: df = pd.DataFrame(l, columns=["a", "b", "c"]) 
   ...: df.groupby(by=["b"], dropna=False).sum()                                                                                                                                                                   
Out[2]: 
     a  c
b        
1.0  2  3
2.0  2  5
NaN  1  4

It was fixed in #35078

@rhshadrach rhshadrach added Bug Groupby Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate labels Oct 22, 2020
@rhshadrach
Copy link
Member

Thanks for reporting this, the fix will be available when 1.2 is released.

@janalysis
Copy link

Any workarounds while I wait for 1.2?

@arw2019
Copy link
Member

arw2019 commented Dec 13, 2020

in case that helps 1.2 is out within a few weeks (and actually the release candidate is out already if you feel like trying it out)

@rhshadrach
Copy link
Member

For a workaround, can replace nan with a value that doesn't exist in the frame, do the groupby, and then refill will nan.

@pramodh941
Copy link

The issue still persists.
"TypeError: group() got an unexpected keyword argument 'dropna'"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Groupby Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Projects
None yet
Development

No branches or pull requests

5 participants