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 std(&self) -> Result<Series, FrameError>
pub fn std(&self) -> Result<Series, FrameError>
Rolling sample standard deviation (ddof=1).
Examples found in repository?
64fn run_api(s: &Series, window: usize, min_periods: Option<usize>, center: bool, a: Agg) -> Series {
65 let r = if center {
66 s.rolling_center(window, min_periods)
67 } else {
68 s.rolling(window, min_periods)
69 };
70 match a {
71 Agg::Var => r.var(),
72 Agg::Std => r.std(),
73 Agg::Skew => r.skew(),
74 Agg::Kurt => r.kurt(),
75 Agg::Sem => r.sem(),
76 Agg::Prod => r.prod(),
77 }
78 .unwrap()
79}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).
Examples found in repository?
64fn run_api(s: &Series, window: usize, min_periods: Option<usize>, center: bool, a: Agg) -> Series {
65 let r = if center {
66 s.rolling_center(window, min_periods)
67 } else {
68 s.rolling(window, min_periods)
69 };
70 match a {
71 Agg::Var => r.var(),
72 Agg::Std => r.std(),
73 Agg::Skew => r.skew(),
74 Agg::Kurt => r.kurt(),
75 Agg::Sem => r.sem(),
76 Agg::Prod => r.prod(),
77 }
78 .unwrap()
79}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.
Examples found in repository?
64fn run_api(s: &Series, window: usize, min_periods: Option<usize>, center: bool, a: Agg) -> Series {
65 let r = if center {
66 s.rolling_center(window, min_periods)
67 } else {
68 s.rolling(window, min_periods)
69 };
70 match a {
71 Agg::Var => r.var(),
72 Agg::Std => r.std(),
73 Agg::Skew => r.skew(),
74 Agg::Kurt => r.kurt(),
75 Agg::Sem => r.sem(),
76 Agg::Prod => r.prod(),
77 }
78 .unwrap()
79}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 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 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 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().
Examples found in repository?
64fn run_api(s: &Series, window: usize, min_periods: Option<usize>, center: bool, a: Agg) -> Series {
65 let r = if center {
66 s.rolling_center(window, min_periods)
67 } else {
68 s.rolling(window, min_periods)
69 };
70 match a {
71 Agg::Var => r.var(),
72 Agg::Std => r.std(),
73 Agg::Skew => r.skew(),
74 Agg::Kurt => r.kurt(),
75 Agg::Sem => r.sem(),
76 Agg::Prod => r.prod(),
77 }
78 .unwrap()
79}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().
Examples found in repository?
64fn run_api(s: &Series, window: usize, min_periods: Option<usize>, center: bool, a: Agg) -> Series {
65 let r = if center {
66 s.rolling_center(window, min_periods)
67 } else {
68 s.rolling(window, min_periods)
69 };
70 match a {
71 Agg::Var => r.var(),
72 Agg::Std => r.std(),
73 Agg::Skew => r.skew(),
74 Agg::Kurt => r.kurt(),
75 Agg::Sem => r.sem(),
76 Agg::Prod => r.prod(),
77 }
78 .unwrap()
79}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().
Examples found in repository?
64fn run_api(s: &Series, window: usize, min_periods: Option<usize>, center: bool, a: Agg) -> Series {
65 let r = if center {
66 s.rolling_center(window, min_periods)
67 } else {
68 s.rolling(window, min_periods)
69 };
70 match a {
71 Agg::Var => r.var(),
72 Agg::Std => r.std(),
73 Agg::Skew => r.skew(),
74 Agg::Kurt => r.kurt(),
75 Agg::Sem => r.sem(),
76 Agg::Prod => r.prod(),
77 }
78 .unwrap()
79}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 row’s own value within its window.
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.