Skip to main content

Resample

Struct Resample 

Source
pub struct Resample<'a> { /* private fields */ }
Expand description

Time-based resampling view over a Series.

Created by Series::resample(freq). Groups values by time buckets defined by the frequency string.

Implementations§

Source§

impl Resample<'_>

Source

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

Resample sum.

Source

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

Resample mean.

Source

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

Resample count.

Source

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

Resample min.

Source

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

Resample max.

Source

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

Resample first non-null value.

Source

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

Resample last non-null value.

Source

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

Apply a custom aggregation function to each time bucket.

Matches pd.Series.resample(freq).apply(func). The function receives a slice of Scalar values for each bucket and must return a single Scalar result.

Source

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

Apply a custom aggregation function (failable) to each time bucket.

Like apply but the closure can return Result.

Source

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

Resample standard deviation (ddof=1).

Source

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

Resample variance.

Source

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

Resample median.

Source

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

Resample product.

Source

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

Aggregate each bucket with one or more named reducers.

Matches series.resample(freq).agg([...]).

Source

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

pandas spelling alias for Self::agg.

Source

pub fn keys(&self) -> Vec<IndexLabel>

Bucket labels in first-observed order.

Source

pub fn indices(&self) -> HashMap<IndexLabel, Vec<usize>>

Mapping from bucket labels to source row positions.

Source

pub fn groups(&self) -> HashMap<IndexLabel, Vec<usize>>

Alias for Self::indices.

Source

pub fn grouper(&self) -> String

Resample frequency descriptor used as the grouper.

Source

pub fn level(&self) -> String

Resample grouping level descriptor.

Source

pub fn ngroups(&self) -> usize

Number of non-empty resample buckets.

Source

pub fn ndim(&self) -> usize

Series resampler dimensionality.

Source

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

Labels excluded from the resample operation.

Source

pub fn get_group(&self, name: &str) -> Result<Series, FrameError>

Return the source rows for one resample bucket.

Source

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

Resample to bucket frequency without reduction.

Current bucketed storage has no explicit empty bucket generation, so this selects the first observed value in each bucket.

Source

pub fn ffill(&self, _limit: Option<usize>) -> Result<Series, FrameError>

Forward-fill each resample bucket.

Source

pub fn bfill(&self, _limit: Option<usize>) -> Result<Series, FrameError>

Backward-fill each resample bucket.

Source

pub fn fillna(&self, value: &Scalar) -> Result<Series, FrameError>

Fill missing resampled values with a scalar.

Source

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

Interpolate missing values after bucket materialization.

Source

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

Select nearest observed value for each current non-empty bucket.

Source

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

Resample quantile using linear interpolation inside each bucket.

Source

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

Resample standard error of the mean.

Source

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

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

Matches pd.Series.resample(freq).skew(). Mirrors fp_types::nanskew which returns Null(NaN) for buckets with fewer than 3 non-missing values or zero sample variance.

Source

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

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

Matches pd.Series.resample(freq).kurt() / .kurtosis(). Mirrors fp_types::nankurt which returns Null(NaN) for buckets with fewer than 4 non-missing values or zero sample variance.

Source

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

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

Source

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

Resample bucket sizes including missing values.

Source

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

Count unique non-missing values in each bucket.

Source

pub fn ohlc(&self) -> Result<DataFrame, FrameError>

Open-high-low-close per resample bucket.

Source

pub fn transform(&self, func: &str) -> Result<Series, FrameError>

Broadcast a named bucket reduction back to the original Series shape.

Source

pub fn pipe<T, F>(&self, func: F) -> Result<T, FrameError>
where F: Fn(&Self) -> Result<T, FrameError>,

Pipe this resampler through a caller-provided function.

Auto Trait Implementations§

§

impl<'a> Freeze for Resample<'a>

§

impl<'a> RefUnwindSafe for Resample<'a>

§

impl<'a> Send for Resample<'a>

§

impl<'a> Sync for Resample<'a>

§

impl<'a> Unpin for Resample<'a>

§

impl<'a> UnsafeUnpin for Resample<'a>

§

impl<'a> UnwindSafe for Resample<'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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.