@@ -3824,15 +3824,75 @@ def expanding(self, *args, **kwargs) -> ExpandingGroupby:
3824
3824
)
3825
3825
3826
3826
@final
3827
- @Substitution (name = "groupby" )
3828
- @Appender (_common_see_also )
3829
3827
def ewm (self , * args , ** kwargs ) -> ExponentialMovingWindowGroupby :
3830
3828
"""
3831
- Return an ewm grouper, providing ewm functionality per group.
3829
+ Return an exponentially weighted moving (EWM) grouper, providing EWM functionality per group.
3830
+
3831
+ Parameters
3832
+ ----------
3833
+ *args : tuple
3834
+ Positional arguments passed to the EWM window constructor.
3835
+ **kwargs : dict
3836
+ Keyword arguments passed to the EWM window constructor, such as:
3837
+
3838
+ com : float, optional
3839
+ Specify decay in terms of center of mass.
3840
+ ``span``, ``halflife``, and ``alpha`` are alternative ways to specify decay.
3841
+ span : float, optional
3842
+ Specify decay in terms of span.
3843
+ halflife : float, optional
3844
+ Specify decay in terms of half-life.
3845
+ alpha : float, optional
3846
+ Specify smoothing factor directly.
3847
+ min_periods : int, default 0
3848
+ Minimum number of observations in the window required to have a value;
3849
+ otherwise, result is ``np.nan``.
3850
+ adjust : bool, default True
3851
+ Divide by decaying adjustment factor to account for imbalance in relative weights.
3852
+ ignore_na : bool, default False
3853
+ Ignore missing values when calculating weights.
3854
+ times : str or array-like of datetime64, optional
3855
+ Times corresponding to the observations.
3856
+ axis : {0 or 'index', 1 or 'columns'}, default 0
3857
+ Axis along which the EWM function is applied.
3832
3858
3833
3859
Returns
3834
3860
-------
3835
- pandas.api.typing.ExponentialMovingWindowGroupby
3861
+ pandas.core.window.ExponentialMovingWindowGroupby
3862
+ An object that supports exponentially weighted moving transformations over each group.
3863
+
3864
+ See Also
3865
+ --------
3866
+ Series.ewm : EWM transformations for Series.
3867
+ DataFrame.ewm : EWM transformations for DataFrames.
3868
+ Series.groupby : Apply a function groupby to a Series.
3869
+ DataFrame.groupby : Apply a function groupby.
3870
+
3871
+ Examples
3872
+ --------
3873
+ >>> df = pd.DataFrame(
3874
+ ... {
3875
+ ... "Class": ["A", "A", "A", "B", "B", "B"],
3876
+ ... "Value": [10, 20, 30, 40, 50, 60],
3877
+ ... }
3878
+ ... )
3879
+ >>> df
3880
+ Class Value
3881
+ 0 A 10
3882
+ 1 A 20
3883
+ 2 A 30
3884
+ 3 B 40
3885
+ 4 B 50
3886
+ 5 B 60
3887
+
3888
+ >>> df.groupby("Class").ewm(com=0.5).mean().reset_index(drop=True)
3889
+ Value
3890
+ 0 10.000000
3891
+ 1 17.500000
3892
+ 2 26.153846
3893
+ 3 40.000000
3894
+ 4 47.500000
3895
+ 5 56.153846
3836
3896
"""
3837
3897
from pandas .core .window import ExponentialMovingWindowGroupby
3838
3898
0 commit comments