pub struct Expanding<'a> { /* private fields */ }Expand description
Expanding window aggregation over a Series.
Created by Series::expanding(). All prior elements are included
in each window computation.
Implementations§
Source§impl Expanding<'_>
impl Expanding<'_>
Sourcepub fn sum(&self) -> Result<Series, FrameError>
pub fn sum(&self) -> Result<Series, FrameError>
Expanding sum.
Matches pd.Series.expanding(min_periods).sum(). Empty
windows (no non-missing values observed yet) emit Null(NaN)
when min_periods >= 1; if the caller explicitly sets
min_periods=0 an empty window still returns 0.0 (pandas
conventional empty-sum identity).
Sourcepub fn mean(&self) -> Result<Series, FrameError>
pub fn mean(&self) -> Result<Series, FrameError>
Expanding mean.
Matches pd.Series.expanding(min_periods).mean(). Empty
windows return Null(NaN) regardless of min_periods — mean
of an empty set is undefined (pandas emits NaN, not 0/0).
Sourcepub fn min(&self) -> Result<Series, FrameError>
pub fn min(&self) -> Result<Series, FrameError>
Expanding minimum.
Sourcepub fn max(&self) -> Result<Series, FrameError>
pub fn max(&self) -> Result<Series, FrameError>
Expanding maximum.
Sourcepub fn std(&self) -> Result<Series, FrameError>
pub fn std(&self) -> Result<Series, FrameError>
Expanding sample standard deviation (ddof=1).
Sourcepub fn var(&self) -> Result<Series, FrameError>
pub fn var(&self) -> Result<Series, FrameError>
Expanding sample variance (ddof=1).
Sourcepub fn prepared(&self) -> &Series
pub fn prepared(&self) -> &Series
View this expanding window as a trailing Rolling whose window spans the
whole series, so var/std can reuse the O(n) compensated online
rolling_var_online instead of the O(n²) per-step two-pass re-fold in
apply_expanding (br-frankenpandas-b3n30).
This is exactly how pandas implements expanding: Expanding subclasses
Rolling with window = len(obj). A trailing window of window >= len
gives window_bounds(i) == (0, i + 1) for every i — the start pointer
never advances, so the online sweep is pure add-only (no remove), which
is precisely the add-only expanding accumulation. window is widened to
max(len, min_periods, 1) so Rolling::validate (which requires
1 <= window and min_periods <= window) accepts an empty series or a
min_periods > len request — both of which expanding allows and which
the per-window emission (Null(NaN) until nobs >= min_periods) handles
unchanged. Bit-faithful to pandas’ compensated roll_var.
The Series every expanding function reads (Rolling::prepared).
Sourcepub fn median(&self) -> Result<Series, FrameError>
pub fn median(&self) -> Result<Series, FrameError>
Expanding median.
Sourcepub fn apply<F>(&self, func: F) -> Result<Series, FrameError>
pub fn apply<F>(&self, func: F) -> Result<Series, FrameError>
Apply a custom function over the expanding window.
Matches series.expanding().apply(func).
Sourcepub fn count(&self) -> Result<Series, FrameError>
pub fn count(&self) -> Result<Series, FrameError>
Expanding count of non-null values.
Matches series.expanding(min_periods).count(): a window of fewer
than min_periods rows is NaN whatever it holds, as pandas gates the
count by position (min_periods was ignored). A float column counts
its non-NaN values off its buffer, an int one each row - each value
was read and each count written as a Scalar (0.66x pandas;
br-frankenpandas-gnic2).
Sourcepub fn quantile(&self, q: f64) -> Result<Series, FrameError>
pub fn quantile(&self, q: f64) -> Result<Series, FrameError>
Expanding quantile.
Matches series.expanding().quantile(q).
Sourcepub fn quantile_with_interpolation(
&self,
q: f64,
interpolation: &str,
) -> Result<Series, FrameError>
pub fn quantile_with_interpolation( &self, q: f64, interpolation: &str, ) -> Result<Series, FrameError>
Expanding quantile with pandas’ interpolation (see
window_quantile).
Matches series.expanding().quantile(q, interpolation).
Sourcepub fn skew(&self) -> Result<Series, FrameError>
pub fn skew(&self) -> Result<Series, FrameError>
Expanding skewness (bias=False, Fisher’s definition).
Matches pd.Series.expanding().skew().
Sourcepub fn kurt(&self) -> Result<Series, FrameError>
pub fn kurt(&self) -> Result<Series, FrameError>
Expanding excess kurtosis (Fisher’s definition, bias=False).
Matches pd.Series.expanding().kurt().
Sourcepub fn kurtosis(&self) -> Result<Series, FrameError>
pub fn kurtosis(&self) -> Result<Series, FrameError>
Alias for kurt() — pandas exposes both spellings on
Series.expanding aggregations.
Sourcepub fn corr(&self, other: &Series) -> Result<Series, FrameError>
pub fn corr(&self, other: &Series) -> Result<Series, FrameError>
Expanding Pearson correlation with another Series.
Matches pd.Series.expanding().corr(other). At each position,
correlates all prior (and current) aligned pairs that have non-null
numeric values in both series. Returns NaN until min_periods and
at least two valid pairs are observed, and when either sample
standard deviation is zero.
Sourcepub fn corr_ddof(
&self,
other: &Series,
ddof: usize,
) -> Result<Series, FrameError>
pub fn corr_ddof( &self, other: &Series, ddof: usize, ) -> Result<Series, FrameError>
pandas’ corr(other, ddof=) (Rolling::corr_ddof over the
growing window).
Sourcepub fn cov(&self, other: &Series) -> Result<Series, FrameError>
pub fn cov(&self, other: &Series) -> Result<Series, FrameError>
Expanding sample covariance (ddof=1) with another Series.
Matches pd.Series.expanding().cov(other). At each position, the
covariance is computed over all aligned pairs where both values
are non-null and numeric.
Sourcepub fn cov_ddof(
&self,
other: &Series,
ddof: usize,
) -> Result<Series, FrameError>
pub fn cov_ddof( &self, other: &Series, ddof: usize, ) -> Result<Series, FrameError>
pandas’ cov(other, ddof=) (Rolling::cov_ddof over the growing
window).
Sourcepub fn sem(&self) -> Result<Series, FrameError>
pub fn sem(&self) -> Result<Series, FrameError>
Expanding standard error of the mean.
Matches series.expanding().sem(). Like std/var, routes through the O(n)
compensated online variance sweep over a full-window trailing Rolling
(sem = std / √nobs) instead of the O(n²) per-step re-fold
(br-frankenpandas-g6qa2).
Sourcepub fn std_ddof(&self, ddof: usize) -> Result<Series, FrameError>
pub fn std_ddof(&self, ddof: usize) -> Result<Series, FrameError>
pandas’ std(ddof=) (Rolling::std_ddof over the growing window).
Sourcepub fn var_ddof(&self, ddof: usize) -> Result<Series, FrameError>
pub fn var_ddof(&self, ddof: usize) -> Result<Series, FrameError>
pandas’ var(ddof=) (Rolling::var_ddof over the growing window).
Sourcepub fn sem_ddof(&self, ddof: usize) -> Result<Series, FrameError>
pub fn sem_ddof(&self, ddof: usize) -> Result<Series, FrameError>
pandas’ sem(ddof=) (Rolling::sem_ddof over the growing window).
Sourcepub fn first(&self) -> Result<Series, FrameError>
pub fn first(&self) -> Result<Series, FrameError>
Expanding first non-null value.
Sourcepub fn last(&self) -> Result<Series, FrameError>
pub fn last(&self) -> Result<Series, FrameError>
Expanding last non-null value.
Sourcepub fn prod(&self) -> Result<Series, FrameError>
pub fn prod(&self) -> Result<Series, FrameError>
Expanding product.
Sourcepub fn rank_with_pct(
&self,
method: &str,
ascending: bool,
pct: bool,
) -> Result<Series, FrameError>
pub fn rank_with_pct( &self, method: &str, ascending: bool, pct: bool, ) -> Result<Series, FrameError>
Rank the current observation against all observations seen so far,
optionally as a percentile in (0, 1] when pct is true
(pandas Expanding.rank(pct=True)).
Sourcepub fn rank(
&self,
method: &str,
ascending: bool,
na_option: &str,
) -> Result<Series, FrameError>
pub fn rank( &self, method: &str, ascending: bool, na_option: &str, ) -> Result<Series, FrameError>
Rank the current observation against all observations seen so far.
Matches series.expanding().rank().
Sourcepub fn agg(&self, funcs: &[&str]) -> Result<DataFrame, FrameError>
pub fn agg(&self, funcs: &[&str]) -> Result<DataFrame, FrameError>
Aggregate with multiple functions, returning a DataFrame.
Matches series.expanding().agg(['sum', 'mean']).
Sourcepub fn aggregate(&self, funcs: &[&str]) -> Result<DataFrame, FrameError>
pub fn aggregate(&self, funcs: &[&str]) -> Result<DataFrame, FrameError>
pandas alias for Self::agg.
Matches series.expanding().aggregate([...]).
Sourcepub fn exclusions(&self) -> Vec<String>
pub fn exclusions(&self) -> Vec<String>
Frozenset-style label set excluded from this expanding window.
Series expanding windows have no excluded columns.
Auto Trait Implementations§
impl<'a> !Freeze for Expanding<'a>
impl<'a> !RefUnwindSafe for Expanding<'a>
impl<'a> !UnwindSafe for Expanding<'a>
impl<'a> Forget for Expanding<'a>
impl<'a> Move for Expanding<'a>
impl<'a> Send for Expanding<'a>
impl<'a> Sync for Expanding<'a>
impl<'a> Unpin for Expanding<'a>
impl<'a> UnsafeUnpin for Expanding<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more