pandas.DataFrame.ewm

pandas 3.1.1 · DataFrame · method

Build an exponentially weighted window for calculations that emphasize recent observations.

Call syntax

DataFrame.ewm(…) Full signature
DataFrame.ewm(
    com=None,
    span=None,
    halflife=None,
    alpha=None,
    min_periods=0,
    adjust=True,
    ignore_na=False,
    times=None,
    method='single',
)

Run the example

Edit the example and select Run Python to see the result.

Parameters

ParameterRequirementAccepted values and behavior
com Optional
Positional or keyword
Default None
float

Set exponential weighting by center of mass.

span Optional
Positional or keyword
Default None
float

Set exponential weighting by span.

halflife Optional
Positional or keyword
Default None
float, str, timedelta

Set the time or number of steps over which the weight falls to half its original value.

alpha Optional
Positional or keyword
Default None
float

Supply the factor controlling the rate of weight decay, or a transparency for a plot.

min_periods Optional
Positional or keyword
Default 0
int

Require this many valid observations in a window before pandas reports a value.

adjust Optional
Positional or keyword
Default True
bool

Choose how initial observations affect normalization of exponential weights.

ignore_na Optional
Positional or keyword
Default False
bool

Choose whether missing observations consume positions in exponential weighting.

times Optional
Positional or keyword
Default None
np.ndarray, Series

Provide observation timestamps used to calculate time-based weights.

method Optional
Positional or keyword
Default 'single'
str {'single', 'table'}

Choose the algorithm used to calculate, align, or fill the result.

Returns

pandas.api.typing.ExponentialMovingWindow