@@ -3835,35 +3835,38 @@ def ewm(
3835
3835
min_periods : int = 0 ,
3836
3836
adjust : bool = True ,
3837
3837
ignore_na : bool = False ,
3838
- axis : Axis = 0 ,
3838
+ axis : int = 0 ,
3839
3839
) -> ExponentialMovingWindowGroupby :
3840
3840
"""
3841
- Return an exponential weighted moving average grouper, providing ewm functionality per group.
3841
+ Return an exponential weighted moving average grouper,
3842
+ providing ewm functionality per group.
3842
3843
3843
3844
Parameters
3844
3845
----------
3845
3846
com : float, optional
3846
3847
Specify decay in terms of center of mass:
3847
3848
:math:`\\ alpha = 1 / (1 + com)` for :math:`com \\ geq 0`.
3848
-
3849
- One and only one of ``com``, ``span``, ``halflife``, or ``alpha`` must be provided.
3849
+ One and only one of ``com``, ``span``, ``halflife``, or ``alpha`` must
3850
+ be provided.
3850
3851
3851
3852
span : float, optional
3852
3853
Specify decay in terms of span:
3853
3854
:math:`\\ alpha = 2 / (span + 1)` for :math:`span \\ geq 1`.
3854
-
3855
- One and only one of ``com``, ``span``, ``halflife``, or ``alpha`` must be provided.
3855
+ One and only one of ``com``, ``span``, ``halflife``, or ``alpha`` must
3856
+ be provided.
3856
3857
3857
3858
halflife : float, optional
3858
3859
Specify decay in terms of half-life:
3859
3860
:math:`\\ alpha = 1 - \\ exp(-\\ ln(2) / halflife)` for :math:`halflife > 0`.
3860
-
3861
- One and only one of ``com``, ``span``, ``halflife``, or ``alpha`` must be provided.
3861
+ One and only one of ``com``, ``span``, ``halflife``, or ``alpha`` must
3862
+ be provided.
3862
3863
3863
3864
alpha : float, optional
3864
- Specify the smoothing factor :math:`\\ alpha` directly, where :math:`0 < \\ alpha \\ leq 1`.
3865
-
3866
- One and only one of ``com``, ``span``, ``halflife``, or ``alpha`` must be provided.
3865
+ Specify the smoothing factor
3866
+ :math:`\\ alpha` directly, where :math:`0 < \\ alpha \\ leq 1`.
3867
+
3868
+ One and only one of ``com``, ``span``, ``halflife``, or ``alpha`` must
3869
+ be provided.
3867
3870
3868
3871
min_periods : int, default 0
3869
3872
Minimum number of observations in window required to have a value;
@@ -3872,26 +3875,27 @@ def ewm(
3872
3875
adjust : bool, default True
3873
3876
Divide by decaying adjustment factor in beginning periods to account
3874
3877
for imbalance in relative weightings (viewing EWMA as a moving average).
3875
-
3878
+
3876
3879
If ``False``, the exponentially weighted function is:
3877
-
3880
+
3878
3881
.. math::
3879
3882
y_t = (1 - \\ alpha) y_{t-1} + \\ alpha x_t
3880
-
3883
+
3881
3884
If ``True``, the exponentially weighted function is:
3882
-
3885
+
3883
3886
.. math::
3884
3887
y_t = \\ frac{\\ sum_{i=0}^t w_i x_{t-i}}{\\ sum_{i=0}^t w_i}
3885
-
3888
+
3886
3889
where :math:`w_i = (1 - \\ alpha)^i`.
3887
3890
3888
3891
ignore_na : bool, default False
3889
3892
If ``True``, missing values are ignored in the calculation.
3890
-
3893
+
3891
3894
If ``False``, missing values are treated as missing.
3892
3895
3893
3896
axis : {0 or 'index', 1 or 'columns'}, default 0
3894
- The axis to use. The value 0 identifies the rows, and 1 identifies the columns.
3897
+ The axis to use. The value 0 identifies the rows, and 1 identifies the
3898
+ columns.
3895
3899
3896
3900
Returns
3897
3901
-------
@@ -3917,7 +3921,7 @@ def ewm(
3917
3921
3918
3922
where :math:`\\ alpha` is the smoothing factor derived from one of the input
3919
3923
decay parameters (``com``, ``span``, ``halflife``, or ``alpha``).
3920
-
3924
+
3921
3925
Only one of ``com``, ``span``, ``halflife``, or ``alpha`` can be specified.
3922
3926
3923
3927
Examples
@@ -3939,7 +3943,7 @@ def ewm(
3939
3943
3940
3944
>>> df.groupby("Class").ewm(span=2).mean()
3941
3945
Value
3942
- Class
3946
+ Class
3943
3947
A 0 10.000000
3944
3948
1 17.500000
3945
3949
2 26.153846
@@ -3949,7 +3953,7 @@ def ewm(
3949
3953
3950
3954
>>> df.groupby("Class").ewm(alpha=0.5, adjust=False).mean()
3951
3955
Value
3952
- Class
3956
+ Class
3953
3957
A 0 10.0
3954
3958
1 15.0
3955
3959
2 22.5
@@ -3959,7 +3963,7 @@ def ewm(
3959
3963
3960
3964
>>> df.groupby("Class").ewm(com=1.0, min_periods=1).std()
3961
3965
Value
3962
- Class
3966
+ Class
3963
3967
A 0 NaN
3964
3968
1 7.071068
3965
3969
2 9.636241
@@ -3972,9 +3976,15 @@ def ewm(
3972
3976
3973
3977
return ExponentialMovingWindowGroupby (
3974
3978
self ._selected_obj ,
3975
- * args ,
3979
+ com = com ,
3980
+ span = span ,
3981
+ halflife = halflife ,
3982
+ alpha = alpha ,
3983
+ min_periods = min_periods ,
3984
+ adjust = adjust ,
3985
+ ignore_na = ignore_na ,
3986
+ axis = axis ,
3976
3987
_grouper = self ._grouper ,
3977
- ** kwargs ,
3978
3988
)
3979
3989
3980
3990
@final
0 commit comments