Skip to content

Commit 1ccc941

Browse files
committed
updated ewm arguments
1 parent a393c31 commit 1ccc941

File tree

1 file changed

+47
-29
lines changed

1 file changed

+47
-29
lines changed

pandas/core/groupby/groupby.py

Lines changed: 47 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ class providing the base-class of operations.
141141

142142
if TYPE_CHECKING:
143143
from pandas._libs.tslibs import BaseOffset
144+
from pandas._libs.tslibs.timedeltas import Timedelta
144145
from pandas._typing import (
145146
Any,
146147
Concatenate,
@@ -3866,39 +3867,49 @@ def expanding(self, *args, **kwargs) -> ExpandingGroupby:
38663867
)
38673868

38683869
@final
3869-
def ewm(self, *args, **kwargs) -> ExponentialMovingWindowGroupby:
3870+
def ewm(
3871+
self,
3872+
com: float | None = None,
3873+
span: float | None = None,
3874+
halflife: float | str | Timedelta | None = None,
3875+
alpha: float | None = None,
3876+
min_periods: int | None = 0,
3877+
adjust: bool = True,
3878+
ignore_na: bool = False,
3879+
times: np.ndarray | Series | None = None,
3880+
method: str = "single",
3881+
) -> ExponentialMovingWindowGroupby:
38703882
"""
38713883
Return an ewm grouper, providing ewm functionality per group.
38723884
38733885
Parameters
38743886
----------
3875-
*args : tuple
3876-
Positional arguments passed to the EWM window constructor.
3877-
**kwargs : dict
3878-
Keyword arguments passed to the EWM window constructor, such as:
3879-
3880-
com : float, optional
3881-
Specify decay in terms of center of mass.
3882-
``span``, ``halflife``, and ``alpha`` are alternative ways to specify
3883-
decay.
3884-
span : float, optional
3885-
Specify decay in terms of span.
3886-
halflife : float, optional
3887-
Specify decay in terms of half-life.
3888-
alpha : float, optional
3889-
Specify smoothing factor directly.
3890-
min_periods : int, default 0
3891-
Minimum number of observations in the window required to have a value;
3892-
otherwise, result is ``np.nan``.
3893-
adjust : bool, default True
3894-
Divide by decaying adjustment factor to account for imbalance in
3887+
com : float, optional
3888+
Specify decay in terms of center of mass.
3889+
Alternative to ``span``, ``halflife``, and ``alpha``.
3890+
3891+
span : float, optional
3892+
Specify decay in terms of span.
3893+
3894+
halflife : float, str, or Timedelta, optional
3895+
Specify decay in terms of half-life.
3896+
3897+
alpha : float, optional
3898+
Specify smoothing factor directly.
3899+
3900+
min_periods : int, default 0
3901+
Minimum number of observations in the window required to have a value;
3902+
otherwise, result is ``np.nan``.
3903+
3904+
adjust : bool, default True
3905+
Divide by decaying adjustment factor to account for imbalance in
38953906
relative weights.
3896-
ignore_na : bool, default False
3897-
Ignore missing values when calculating weights.
3898-
times : str or array-like of datetime64, optional
3899-
Times corresponding to the observations.
3900-
axis : {0 or 'index', 1 or 'columns'}, default 0
3901-
Axis along which the EWM function is applied.
3907+
3908+
ignore_na : bool, default False
3909+
Ignore missing values when calculating weights.
3910+
3911+
times : str or array-like of datetime64, optional
3912+
Times corresponding to the observations.
39023913
39033914
Returns
39043915
-------
@@ -3944,9 +3955,16 @@ def ewm(self, *args, **kwargs) -> ExponentialMovingWindowGroupby:
39443955

39453956
return ExponentialMovingWindowGroupby(
39463957
self._selected_obj,
3947-
*args,
3958+
com=com,
3959+
span=span,
3960+
halflife=halflife,
3961+
alpha=alpha,
3962+
min_periods=min_periods,
3963+
adjust=adjust,
3964+
ignore_na=ignore_na,
3965+
times=times,
3966+
method=method,
39483967
_grouper=self._grouper,
3949-
**kwargs,
39503968
)
39513969

39523970
@final

0 commit comments

Comments
 (0)