Allow .expanding() to be called on groupby object · Issue #12738 · pandas-dev/pandas (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

@lminer

Description

@lminer

Right now when I want to have expanding operate at the level of a group I have to apply a convenience function like so:

def expanding_sum(s): return s.expanding().sum()

expanded_sum = df.groupby('mygroup')['mynum'].apply(expanding_sum)

Would be nice to be able to call a method directly on a groupby object:

expanded_sum = df.groupby('mygroup')['mynum'].expanding().sum()