Skip to main content

Rolling

Struct Rolling 

Source
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<'_>

Source

pub fn prepared(&self) -> &Series

The Series every window function reads: the source with +-inf as NaN, as pandas’ _prep_values hands it to its kernels and to apply.

Source

pub fn sum(&self) -> Result<Series, FrameError>

Rolling sum.

Source

pub fn mean(&self) -> Result<Series, FrameError>

Rolling mean.

Source

pub fn min(&self) -> Result<Series, FrameError>

Rolling minimum.

Source

pub fn max(&self) -> Result<Series, FrameError>

Rolling maximum.

Source

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.

Source

pub fn std(&self) -> Result<Series, FrameError>

Rolling sample standard deviation (ddof=1).

Source

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).

Source

pub fn var(&self) -> Result<Series, FrameError>

Rolling sample variance (ddof=1).

Source

pub fn median(&self) -> Result<Series, FrameError>

Rolling median.

Source

pub fn first(&self) -> Result<Series, FrameError>

Rolling first non-null value.

Source

pub fn last(&self) -> Result<Series, FrameError>

Rolling last non-null value.

Source

pub fn prod(&self) -> Result<Series, FrameError>

Rolling product.

Source

pub fn quantile(&self, q: f64) -> Result<Series, FrameError>

Rolling quantile.

Matches series.rolling(window).quantile(q).

Source

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).

Source

pub fn apply<F>(&self, func: F) -> Result<Series, FrameError>
where F: Fn(&[f64]) -> f64,

Apply a custom function over the rolling window.

Matches series.rolling(window).apply(func).

Source

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.

Source

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.

Source

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.

Source

pub fn cov_ddof( &self, other: &Series, ddof: usize, ) -> Result<Series, FrameError>

pandas’ cov(other, ddof=): the co-moment over nobs - ddof.

Source

pub fn skew(&self) -> Result<Series, FrameError>

Rolling skewness (bias=False, Fisher’s definition).

Matches pd.Series.rolling(window).skew().

Source

pub fn kurt(&self) -> Result<Series, FrameError>

Rolling excess kurtosis (Fisher’s definition, bias=False).

Matches pd.Series.rolling(window).kurt().

Source

pub fn kurtosis(&self) -> Result<Series, FrameError>

Alias for kurt() — pandas exposes both spellings on Series.rolling aggregations.

Source

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.

Source

pub fn aggregate(&self, funcs: &[&str]) -> Result<DataFrame, FrameError>

pandas alias for Self::agg.

Matches series.rolling(window).aggregate([...]).

Source

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).

Source

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).

Source

pub fn var_ddof(&self, ddof: usize) -> Result<Series, FrameError>

pandas’ var(ddof=) (Self::std_ddof squared).

Source

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).

Source

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.

Source

pub fn exclusions(&self) -> Vec<String>

Frozenset-style label set excluded from this rolling window.

Series rolling windows have no excluded columns.

Source

pub fn ndim(&self) -> usize

Number of dimensions of the underlying object. Series rolling is 1D.

Trait Implementations§

Source§

impl<'a> Debug for Rolling<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !Freeze for Rolling<'a>

§

impl<'a> !RefUnwindSafe for Rolling<'a>

§

impl<'a> !UnwindSafe for Rolling<'a>

§

impl<'a> Send for Rolling<'a>

§

impl<'a> Sync for Rolling<'a>

§

impl<'a> Unpin for Rolling<'a>

§

impl<'a> UnsafeUnpin for Rolling<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.