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

Comments

Projects
None yet
4 participants
@qiaoqiaozhu

qiaoqiaozhu commented Feb 21, 2018

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

This comment has been minimized.

Contributor

jreback commented Feb 21, 2018

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

@qiaoqiaozhu

This comment has been minimized.

qiaoqiaozhu commented Feb 21, 2018

I'm using pandas 0.22.0 build py36h0a44026_0

@jreback

This comment has been minimized.

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

This comment has been minimized.

Contributor

shangyian commented Feb 26, 2018

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

@gfyoung

This comment has been minimized.

Member

gfyoung commented Feb 26, 2018

Go for it!

@jreback jreback modified the milestones: Next Major Release, 0.23.0 Feb 28, 2018

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