Skip to content
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

Groupby.cumsum()'s skipna option does not work #19806

Closed
qiaoqiaozhu opened this issue Feb 21, 2018 · 5 comments · Fixed by #19914
Closed

Groupby.cumsum()'s skipna option does not work #19806

qiaoqiaozhu opened this issue Feb 21, 2018 · 5 comments · Fixed by #19914

Comments

@qiaoqiaozhu
Copy link

Code Sample, a copy-pastable example if possible

df = pd.concat([pd.DataFrame({'x':np.random.randn(3), 'gp': 'a'}), pd.DataFrame({'x':np.random.randn(3), 'gp': 'b'})])
df.groupby('gp')['x'].cumsum(skipna=False)

Problem description

DataFrame.cumsum(skipna=False) works.
But DataFrame.groupby['var'].cumsum(skipna=False) does not work.

as seen from the above codes. Error message says numpy operations are not valid with groupby. This is inconsistent behavior, and is in conflict with docs http://pandas.pydata.org/pandas-docs/version/0.17.0/generated/pandas.core.groupby.DataFrameGroupBy.cumsum.html

@jreback
Copy link
Contributor

jreback commented Feb 21, 2018

pls show_versions() - you are pointing to very old docs

@qiaoqiaozhu
Copy link
Author

I'm using pandas 0.22.0 build py36h0a44026_0

@jreback
Copy link
Contributor

jreback commented Feb 21, 2018

yeah we are being a little strict on this and immeditately rejecting this to prevent users from doing np.cumsm(df.groupby(...)) which is an invalid construct. So skipna just needed to be added to the signature and passed thru (for all for the cum* methods). want to do a PR?

cc @gfyoung

@jreback jreback added this to the Next Major Release milestone Feb 21, 2018
@shangyian
Copy link
Contributor

If no one else is working on this, I'll take a stab at a PR

@gfyoung
Copy link
Member

gfyoung commented Feb 26, 2018

Go for it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants