Skip to content

Commit c38e1f1

Browse files
authored
DOC: Updated groupby.ewm arguments (#61334)
* updated ewm arguments * added method argument to docstring * removed unexpected indentation * updated method parameter description * precommit
1 parent f8d5a16 commit c38e1f1

File tree

1 file changed

+53
-30
lines changed

1 file changed

+53
-30
lines changed

Diff for: pandas/core/groupby/groupby.py

+53-30
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ class providing the base-class of operations.
142142

143143
if TYPE_CHECKING:
144144
from pandas._libs.tslibs import BaseOffset
145+
from pandas._libs.tslibs.timedeltas import Timedelta
145146
from pandas._typing import (
146147
Any,
147148
Concatenate,
@@ -3872,39 +3873,54 @@ def expanding(self, *args, **kwargs) -> ExpandingGroupby:
38723873
)
38733874

38743875
@final
3875-
def ewm(self, *args, **kwargs) -> ExponentialMovingWindowGroupby:
3876+
def ewm(
3877+
self,
3878+
com: float | None = None,
3879+
span: float | None = None,
3880+
halflife: float | str | Timedelta | None = None,
3881+
alpha: float | None = None,
3882+
min_periods: int | None = 0,
3883+
adjust: bool = True,
3884+
ignore_na: bool = False,
3885+
times: np.ndarray | Series | None = None,
3886+
method: str = "single",
3887+
) -> ExponentialMovingWindowGroupby:
38763888
"""
38773889
Return an ewm grouper, providing ewm functionality per group.
38783890
38793891
Parameters
38803892
----------
3881-
*args : tuple
3882-
Positional arguments passed to the EWM window constructor.
3883-
**kwargs : dict
3884-
Keyword arguments passed to the EWM window constructor, such as:
3885-
3886-
com : float, optional
3887-
Specify decay in terms of center of mass.
3888-
``span``, ``halflife``, and ``alpha`` are alternative ways to specify
3889-
decay.
3890-
span : float, optional
3891-
Specify decay in terms of span.
3892-
halflife : float, optional
3893-
Specify decay in terms of half-life.
3894-
alpha : float, optional
3895-
Specify smoothing factor directly.
3896-
min_periods : int, default 0
3897-
Minimum number of observations in the window required to have a value;
3898-
otherwise, result is ``np.nan``.
3899-
adjust : bool, default True
3900-
Divide by decaying adjustment factor to account for imbalance in
3901-
relative weights.
3902-
ignore_na : bool, default False
3903-
Ignore missing values when calculating weights.
3904-
times : str or array-like of datetime64, optional
3905-
Times corresponding to the observations.
3906-
axis : {0 or 'index', 1 or 'columns'}, default 0
3907-
Axis along which the EWM function is applied.
3893+
com : float, optional
3894+
Specify decay in terms of center of mass.
3895+
Alternative to ``span``, ``halflife``, and ``alpha``.
3896+
3897+
span : float, optional
3898+
Specify decay in terms of span.
3899+
3900+
halflife : float, str, or Timedelta, optional
3901+
Specify decay in terms of half-life.
3902+
3903+
alpha : float, optional
3904+
Specify smoothing factor directly.
3905+
3906+
min_periods : int, default 0
3907+
Minimum number of observations in the window required to have a value;
3908+
otherwise, result is ``np.nan``.
3909+
3910+
adjust : bool, default True
3911+
Divide by decaying adjustment factor to account for imbalance in
3912+
relative weights.
3913+
3914+
ignore_na : bool, default False
3915+
Ignore missing values when calculating weights.
3916+
3917+
times : str or array-like of datetime64, optional
3918+
Times corresponding to the observations.
3919+
3920+
method : {'single', 'table'}, default 'single'
3921+
Execute the operation per group independently (``'single'``) or over the
3922+
entire object before regrouping (``'table'``). Only applicable to
3923+
``mean()``, and only when using ``engine='numba'``.
39083924
39093925
Returns
39103926
-------
@@ -3950,9 +3966,16 @@ def ewm(self, *args, **kwargs) -> ExponentialMovingWindowGroupby:
39503966

39513967
return ExponentialMovingWindowGroupby(
39523968
self._selected_obj,
3953-
*args,
3969+
com=com,
3970+
span=span,
3971+
halflife=halflife,
3972+
alpha=alpha,
3973+
min_periods=min_periods,
3974+
adjust=adjust,
3975+
ignore_na=ignore_na,
3976+
times=times,
3977+
method=method,
39543978
_grouper=self._grouper,
3955-
**kwargs,
39563979
)
39573980

39583981
@final

0 commit comments

Comments
 (0)