Skip to content

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

Closed
@qiaoqiaozhu

Description

@qiaoqiaozhu

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

Activity

jreback

jreback commented on Feb 21, 2018

@jreback
Contributor

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

qiaoqiaozhu

qiaoqiaozhu commented on Feb 21, 2018

@qiaoqiaozhu
Author

I'm using pandas 0.22.0 build py36h0a44026_0

jreback

jreback commented on Feb 21, 2018

@jreback
Contributor

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

added this to the Next Major Release milestone on Feb 21, 2018
shangyian

shangyian commented on Feb 26, 2018

@shangyian
Contributor

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

gfyoung

gfyoung commented on Feb 26, 2018

@gfyoung
Member

Go for it!

modified the milestones: Next Major Release, 0.23.0 on Feb 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      Participants

      @jreback@gfyoung@shangyian@qiaoqiaozhu

      Issue actions

        Groupby.cumsum()'s skipna option does not work · Issue #19806 · pandas-dev/pandas