hipdf.Series.ewm

Contents

hipdf.Series.ewm#

22 min read time

Applies to Linux

Series.ewm(com: float | None = None, span: float | None = None, halflife: float | None = None, alpha: float | None = None, min_periods: int | None = 0, adjust: bool = True, ignore_na: bool = False, axis: int = 0, times: str | ndarray | None = None, method: Literal['single', 'table'] = 'single')#

Provide exponential weighted (EW) functions. Available EW functions: mean() Exactly one parameter: com, span, halflife, or alpha must be provided.

Parameters#

comfloat, optional

Specify decay in terms of center of mass, \(\alpha = 1 / (1 + com)\), for \(com \geq 0\).

spanfloat, optional

Specify decay in terms of span, \(\alpha = 2 / (span + 1)\), for \(span \geq 1\).

halflifefloat, str, timedelta, optional

Specify decay in terms of half-life, \(\alpha = 1 - \exp\left(-\ln(2) / halflife\right)\), for \(halflife > 0\).

alphafloat, optional

Specify smoothing factor \(\alpha\) directly, \(0 < \alpha \leq 1\).

min_periodsint, default 0

Not Supported

adjustbool, default True

Controls assumptions about the first value in the sequence. https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.ewm.html for details.

ignore_nabool, default False

Not Supported

axis{0, 1}, default 0

Not Supported

timesstr, np.ndarray, Series, default None

Not Supported

Returns#

ExponentialMovingWindow object

Notes#

cuDF input data may contain both nulls and nan values. For the purposes of this method, they are taken to have the same meaning, meaning nulls in cuDF will affect the result the same way that nan values would using the equivalent pandas method.

Examples#

>>> df = cudf.DataFrame({'B': [0, 1, 2, cudf.NA, 4]})
>>> df
      B
0     0
1     1
2     2
3  <NA>
4     4
>>> df.ewm(com=0.5).mean()
          B
0  0.000000
1  0.750000
2  1.615385
3  1.615385
4  3.670213
>>> df.ewm(com=0.5, adjust=False).mean()
          B
0  0.000000
1  0.666667
2  1.555556
3  1.555556
4  3.650794