pub struct Rolling<'a> { /* private fields */ }Expand description
Rolling window aggregation over a Series.
Created by Series::rolling(). Provides methods for computing
rolling statistics over a sliding window.
Implementations§
Source§impl Rolling<'_>
impl Rolling<'_>
Sourcepub fn sum(&self) -> Result<Series, FrameError>
pub fn sum(&self) -> Result<Series, FrameError>
Rolling sum.
Sourcepub fn mean(&self) -> Result<Series, FrameError>
pub fn mean(&self) -> Result<Series, FrameError>
Rolling mean.
Sourcepub fn min(&self) -> Result<Series, FrameError>
pub fn min(&self) -> Result<Series, FrameError>
Rolling minimum.
Sourcepub fn max(&self) -> Result<Series, FrameError>
pub fn max(&self) -> Result<Series, FrameError>
Rolling maximum.
Sourcepub fn window_bounds(&self, i: usize, len: usize) -> (usize, usize)
pub fn window_bounds(&self, i: usize, len: usize) -> (usize, usize)
Half-open window bounds [start, end) for output position i. Both
bounds are non-decreasing in i for trailing AND centered windows, so a
two-pointer sweep can slide an incremental structure across them.
Sourcepub fn std(&self) -> Result<Series, FrameError>
pub fn std(&self) -> Result<Series, FrameError>
Rolling sample standard deviation (ddof=1).
Sourcepub fn count(&self) -> Result<Series, FrameError>
pub fn count(&self) -> Result<Series, FrameError>
Rolling count of non-null values.
pandas count() is special: min_periods checks WINDOW SIZE, not non-null count. This differs from sum/mean/etc. where min_periods checks non-null count. If the window has at least min_periods elements, count returns the number of non-nulls (which can be 0).
Sourcepub fn var(&self) -> Result<Series, FrameError>
pub fn var(&self) -> Result<Series, FrameError>
Rolling sample variance (ddof=1).
Sourcepub fn median(&self) -> Result<Series, FrameError>
pub fn median(&self) -> Result<Series, FrameError>
Rolling median.
Sourcepub fn first(&self) -> Result<Series, FrameError>
pub fn first(&self) -> Result<Series, FrameError>
Rolling first non-null value.
Sourcepub fn last(&self) -> Result<Series, FrameError>
pub fn last(&self) -> Result<Series, FrameError>
Rolling last non-null value.
Sourcepub fn prod(&self) -> Result<Series, FrameError>
pub fn prod(&self) -> Result<Series, FrameError>
Rolling product.
Sourcepub fn quantile(&self, q: f64) -> Result<Series, FrameError>
pub fn quantile(&self, q: f64) -> Result<Series, FrameError>
Rolling quantile.
Matches series.rolling(window).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>
Rolling quantile with pandas’ interpolation (‘linear’, ‘lower’,
‘higher’, ‘nearest’, ‘midpoint’; see window_quantile).
Matches series.rolling(window).quantile(q, interpolation).
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 rolling window.
Matches series.rolling(window).apply(func).
Sourcepub fn corr(&self, other: &Series) -> Result<Series, FrameError>
pub fn corr(&self, other: &Series) -> Result<Series, FrameError>
Rolling pairwise correlation with another Series.
Matches series.rolling(window).corr(other). Computes Pearson
correlation over each rolling window.
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=): the ddof cancels, but for NaN where a
window holds ddof observations or fewer.
Sourcepub fn cov(&self, other: &Series) -> Result<Series, FrameError>
pub fn cov(&self, other: &Series) -> Result<Series, FrameError>
Rolling pairwise covariance with another Series.
Matches series.rolling(window).cov(other). Computes sample
covariance (ddof=1) over each rolling window.
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=): the co-moment over nobs - ddof.
Sourcepub fn skew(&self) -> Result<Series, FrameError>
pub fn skew(&self) -> Result<Series, FrameError>
Rolling skewness (bias=False, Fisher’s definition).
Matches pd.Series.rolling(window).skew().
Sourcepub fn kurt(&self) -> Result<Series, FrameError>
pub fn kurt(&self) -> Result<Series, FrameError>
Rolling excess kurtosis (Fisher’s definition, bias=False).
Matches pd.Series.rolling(window).kurt().
Sourcepub fn kurtosis(&self) -> Result<Series, FrameError>
pub fn kurtosis(&self) -> Result<Series, FrameError>
Alias for kurt() — pandas exposes both spellings on
Series.rolling aggregations.
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.rolling(window).agg(['sum', 'mean']). Returns a
DataFrame with one column per function, same index as the input.
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.rolling(window).aggregate([...]).
Sourcepub fn sem(&self) -> Result<Series, FrameError>
pub fn sem(&self) -> Result<Series, FrameError>
Rolling standard error of the mean.
Matches series.rolling(window).sem(). sem = std / √nobs, so it shares
the O(n) compensated online variance sweep (rolling_var_online) used by
std/var rather than the O(n·w) per-window two-pass 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=): sqrt(m2 / (nobs - ddof)), NaN where
nobs <= ddof (Self::std is ddof 1).
Sourcepub fn var_ddof(&self, ddof: usize) -> Result<Series, FrameError>
pub fn var_ddof(&self, ddof: usize) -> Result<Series, FrameError>
pandas’ var(ddof=) (Self::std_ddof squared).
Sourcepub fn sem_ddof(&self, ddof: usize) -> Result<Series, FrameError>
pub fn sem_ddof(&self, ddof: usize) -> Result<Series, FrameError>
pandas’ sem(ddof=), its own formula: the ddof-1 std over
sqrt(count - ddof) (the std keeps ddof 1).
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 within each rolling window.
Matches series.rolling(window).rank(). The emitted value is the
rank of the window’s last value within it: the row’s own for a
trailing window, the window’s newest (not its middle) when centered,
as pandas.
Sourcepub fn exclusions(&self) -> Vec<String>
pub fn exclusions(&self) -> Vec<String>
Frozenset-style label set excluded from this rolling window.
Series rolling windows have no excluded columns.