Skip to content

ENH: support .groupby().ewm() directly #16037

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

Closed
jreback opened this issue Apr 17, 2017 · 3 comments · Fixed by #37878
Closed

ENH: support .groupby().ewm() directly #16037

jreback opened this issue Apr 17, 2017 · 3 comments · Fixed by #37878
Labels
Enhancement Groupby Window rolling, ewma, expanding
Milestone

Comments

@jreback
Copy link
Contributor

jreback commented Apr 17, 2017

would be nice to support .groupby().ewm() directly.

In [2]: df = pd.DataFrame({'tid': np.random.randint(0, 10, size=100), 'value': np.random.randn(100)})

In [3]: df.groupby('tid').rolling(3).value.mean()
Out[3]: 
tid    
0    3          NaN
     6          NaN
     10   -0.596818
     16   -0.619943
     23   -0.688623
     24   -0.167816
             ...   
9    74    0.575155
     80    1.046240
     81    0.279683
     85    0.296154
     86   -0.267774
     92    0.320419
Name: value, dtype: float64

In [4]: df.groupby('tid').apply(lambda x: x.ewm(5).value.mean())
Out[4]: 
tid    
0    3    -1.182125
     6    -0.118510
     10   -0.616044
     16   -0.820601
     23   -0.435397
     24   -0.279619
             ...   
9    74    0.505610
     80    0.657754
     81    0.451367
     85    0.372517
     86    0.226676
     92    0.429832
Name: value, dtype: float64

@jreback jreback added Difficulty Intermediate Enhancement Groupby Numeric Operations Arithmetic, Comparison, and Logical operations labels Apr 17, 2017
@jreback jreback added this to the Next Major Release milestone Apr 17, 2017
@vallahaye
Copy link

Hello everyone!

Is this issue still planned for a future major release ?
I'm currently building a library over Pandas at my job and having the possibility to call "ewm" on a SeriesGroupBy object would reduce the complexity of my code.
Also on a performance standpoint, I've recently come across issues when grouping my data by more than one columns (which leaded to the creation of around two million groups). Would having the "ewm" function accessible directly on the SeriesGroupBy object be beneficial for the execution speed ? I imagine it would take some kind of "fast path" in the execution process by not having to call a lambda function (grouped.transform(lambda x: x.ewm...)) for each group.

Thanks in advance

@TomAugspurger
Copy link
Contributor

I don't think anyone is working on this right now.

@vallahaye
Copy link

Yeah I have to feeling it's been forgotten over the years. How hard is it to implement such a feature ? Am I right thinking the performances would be better ? Maybe I could have a look at it someday.

@mroeschke mroeschke added Window rolling, ewma, expanding and removed Numeric Operations Arithmetic, Comparison, and Logical operations labels Oct 16, 2020
@jreback jreback modified the milestones: Contributions Welcome, 1.2 Nov 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Groupby Window rolling, ewma, expanding
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants