Closed
Description
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 commentedon Feb 21, 2018
pls show_versions() - you are pointing to very old docs
qiaoqiaozhu commentedon Feb 21, 2018
I'm using pandas 0.22.0 build py36h0a44026_0
jreback commentedon 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. Soskipna
just needed to be added to the signature and passed thru (for all for the cum* methods). want to do a PR?cc @gfyoung
shangyian commentedon Feb 26, 2018
If no one else is working on this, I'll take a stab at a PR
gfyoung commentedon Feb 26, 2018
Go for it!