Skip to content

Commit bbf5e2b

Browse files
committed
DOC: Add documentation for groupby.ewm()
1 parent 337254f commit bbf5e2b

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

pandas/core/groupby/groupby.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3929,7 +3929,7 @@ def ewm(
39293929
... }
39303930
... )
39313931
>>> df
3932-
Class Value
3932+
Class Value
39333933
0 A 10
39343934
1 A 20
39353935
2 A 30
@@ -3938,8 +3938,8 @@ def ewm(
39383938
5 B 60
39393939
39403940
>>> df.groupby("Class").ewm(span=2).mean()
3941-
Value
3942-
Class
3941+
Value
3942+
Class
39433943
A 0 10.000000
39443944
1 17.500000
39453945
2 26.153846
@@ -3948,24 +3948,24 @@ def ewm(
39483948
5 56.153846
39493949
39503950
>>> df.groupby("Class").ewm(alpha=0.5, adjust=False).mean()
3951-
Value
3952-
Class
3953-
A 0 10.000000
3954-
1 15.000000
3955-
2 22.500000
3956-
B 3 40.000000
3957-
4 45.000000
3958-
5 52.500000
3951+
Value
3952+
Class
3953+
A 0 10.0
3954+
1 15.0
3955+
2 22.5
3956+
B 3 40.0
3957+
4 45.0
3958+
5 52.5
39593959
39603960
>>> df.groupby("Class").ewm(com=1.0, min_periods=1).std()
39613961
Value
3962-
Class
3963-
A 0 0.000000
3964-
1 7.500000
3965-
2 10.606602
3966-
B 3 0.000000
3967-
4 7.500000
3968-
5 10.606602
3962+
Class
3963+
A 0 NaN
3964+
1 7.071068
3965+
2 9.636241
3966+
B 3 NaN
3967+
4 7.071068
3968+
5 9.636241
39693969
"""
39703970

39713971
from pandas.core.window import ExponentialMovingWindowGroupby

0 commit comments

Comments
 (0)