pub struct Ewm<'a> { /* private fields */ }Expand description
Exponentially weighted moving window aggregation over a Series.
Created by Series::ewm(). Uses the recursive EWM formula:
y_t = alpha * x_t + (1 - alpha) * y_{t-1}
Implementations§
Source§impl Ewm<'_>
impl Ewm<'_>
Sourcepub fn ignoring_na(self, ignore_na: bool) -> Self
pub fn ignoring_na(self, ignore_na: bool) -> Self
pandas’ ignore_na=True: a missing row leaves the weights as they
were (with false, the default, it decays them), in every method.
Sourcepub fn with_deltas(self, deltas: Vec<f64>) -> Self
pub fn with_deltas(self, deltas: Vec<f64>) -> Self
pandas’ times= with a halflife: deltas[i - 1] is the time from
row i - 1 to row i over the halflife, and mean decays step i
by (1 - alpha) ** deltas[i - 1]. pandas’ other EWM methods decay by
1 - alpha whatever the times, and so do these.
Sourcepub fn mean(&self) -> Result<Series, FrameError>
pub fn mean(&self) -> Result<Series, FrameError>
EWM mean.
Matches series.ewm(span=...).mean() with ignore_na=False. Honors
this window’s adjust and min_periods (issue #19): with the default
adjust=True the smoothed value is the normalized weighted average
sum_i (1-a)^i x_{t-i} / sum_i (1-a)^i, computed via pandas’ exact
online old_wt recurrence (br-frankenpandas-usdk2); with
adjust=False it is the recursive form y_t = (1-a)*y_{t-1} + a*x_t
(renormalized across NaN gaps exactly as pandas’ kernel). Outputs are
NaN until max(min_periods, 1) observations have been seen. Per
br-frankenpandas-mm77i the last EWM value is carried forward for
missing inputs; with ignore_na=False a missing input still decays
old_wt.
Sourcepub fn sum(&self) -> Result<Series, FrameError>
pub fn sum(&self) -> Result<Series, FrameError>
EWM weighted sum.
Matches series.ewm(span=...).sum(). Uses the recursive
formula s_t = x_t + (1 - alpha) * s_{t-1} where alpha is
the smoothing factor derived from span. Leading missing values
stay null until the first observation is seen; once seen, an
internal NaN gap still decays the running sum by (1 - alpha)
and the decayed value is carried forward (ignore_na=False,
exactly pandas’ aggregations.pyx::ewm with normalize=False).
Honors this window’s min_periods (issue #19); pandas raises
NotImplementedError for sum with adjust=False, mirrored
here as CompatibilityRejected.
Sourcepub fn cov(&self, other: &Series) -> Result<Series, FrameError>
pub fn cov(&self, other: &Series) -> Result<Series, FrameError>
EWM covariance with another Series (sample, ddof=1).
Matches series.ewm(span=...).cov(other). Uses Welford-style
online updates with exponential weighting over aligned
positions; missing positions on either side emit Null(NaN)
without advancing the running estimate. Returns
LengthMismatch when inputs differ in length.
Sourcepub fn cov_bias(&self, other: &Series, bias: bool) -> Result<Series, FrameError>
pub fn cov_bias(&self, other: &Series, bias: bool) -> Result<Series, FrameError>
pandas’ cov(other, bias=): bias=True is the weighted covariance
without the debias factor (Self::cov is bias=False).
Sourcepub fn corr(&self, other: &Series) -> Result<Series, FrameError>
pub fn corr(&self, other: &Series) -> Result<Series, FrameError>
EWM Pearson correlation with another Series.
Matches series.ewm(span=...).corr(other). Uses the same
exponentially weighted covariance path as cov(other) and
normalizes by the two exponentially weighted standard deviations.
Sourcepub fn std(&self) -> Result<Series, FrameError>
pub fn std(&self) -> Result<Series, FrameError>
EWM standard deviation (sample, ddof=1).
Matches series.ewm(span=...).std().
Sourcepub fn var(&self) -> Result<Series, FrameError>
pub fn var(&self) -> Result<Series, FrameError>
EWM variance (sample, ddof=1).
Uses the online formula for exponentially weighted variance.
Matches series.ewm(span=...).var().
Sourcepub fn var_bias(&self, bias: bool) -> Result<Series, FrameError>
pub fn var_bias(&self, bias: bool) -> Result<Series, FrameError>
pandas’ var(bias=): bias=True is the weighted variance without the
debias factor (Self::var is bias=False).
Sourcepub fn std_bias(&self, bias: bool) -> Result<Series, FrameError>
pub fn std_bias(&self, bias: bool) -> Result<Series, FrameError>
pandas’ std(bias=): the square root of Self::var_bias.
Sourcepub fn agg(&self, funcs: &[&str]) -> Result<DataFrame, FrameError>
pub fn agg(&self, funcs: &[&str]) -> Result<DataFrame, FrameError>
Apply one or more aggregation functions and return a DataFrame
keyed by function name. Matches series.ewm(span=...).agg(['mean', 'sum']).
Per br-frankenpandas-mvynk.
Sourcepub fn aggregate(&self, funcs: &[&str]) -> Result<DataFrame, FrameError>
pub fn aggregate(&self, funcs: &[&str]) -> Result<DataFrame, FrameError>
pandas alias for Self::agg. Matches ewm.aggregate([...]).
Sourcepub fn online(&self) -> Result<OnlineEwm, FrameError>
pub fn online(&self) -> Result<OnlineEwm, FrameError>
Begin an online (streaming) EWM accumulation.
Matches series.ewm(span=...).online() (pandas 1.4+). Returns
an OnlineEwm that maintains running mean state across
incremental update(value) calls without re-scanning the input
each time. Per br-frankenpandas-mvynk.
Sourcepub fn exclusions(&self) -> Vec<String>
pub fn exclusions(&self) -> Vec<String>
Frozenset-style label set of columns excluded from this window.
Matches EWM.exclusions, which on 2.2.3 is a frozenset, empty for a
Series window. EWM on a Series has no excluded columns; returns an
empty Vec.
⚠️ Half the earlier citation was false: pd.api.indexers.BaseIndexer
has NO exclusions (measured 2.2.3 – its only public member is
get_window_bounds). The attribute belongs to the window/groupby
object, not to the indexer.
Per br-frankenpandas-mvynk.