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 closed(self, closed: &str) -> Self

Source

pub fn sharing(self, layout: &Arc<ResampleLayout>) -> Self

This view keeping its rows’ bins in layout, which every reduction of one resampler - over the same rows, freq and options - shares (br-frankenpandas-xmwso). Bins kept for another number of rows are never read.

Source

pub fn label(self, label: &str) -> Self

Source

pub fn origin(self, origin: &str) -> Self

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) -> Result<Vec<IndexLabel>, FrameError>

Bucket labels in first-observed order; a rule past the bin cap is refused (br-frankenpandas-effk4).

Source

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

Mapping from bucket labels to source row positions.

Source

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

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) -> Result<usize, FrameError>

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 upsample( &self, method: &str, limit: Option<usize>, fill_value: Option<&Scalar>, ) -> Result<Series, FrameError>

pandas’ upsampling (Resampler._upsample): method ‘asfreq’, ‘ffill’ / ‘pad’, ‘bfill’ / ‘backfill’ or ‘nearest’ is series.reindex(edges, method, limit, fill_value) onto the bin edges on the closed side (whatever the label). Every timestamped row takes part, a NaN-valued one included: a fill carries its NaN (they were skipped, so ffill ran past a NaN row). fill_value fills only the edges no row matched, not a row’s own NaN. A repeated timestamp is pandas’ ValueError; limit bounds the inexact matches per source row and must be positive. A nullable column keeps its dtype (<NA> where nothing matched); an int one becomes float only when an edge is left missing.

Source

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

Resample to bucket frequency without reduction: each bin edge takes the value AT it exactly, else NaN - a value later in the same bucket is not picked up (br-frankenpandas-kmy0b, probed live pandas 2.2.3). See Self::upsample.

Source

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

Forward-fill onto the bin edges from the ORIGINAL rows: series.reindex(edges, method="ffill", limit). Each edge takes the latest row at-or-before it; limit counts consecutive filled edges past a row, not buckets-with-data. Probed live pandas 2.2.3 (br-frankenpandas-kmy0b): obs at 01T00=1, 01T06=2, 03T12=3 with freq D gives ffill -> [1, 2, 2] and ffill(limit=1) -> [1, 2, NaN].

Source

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

Backward-fill onto the bin edges: the mirror of Self::ffill. Probed live pandas 2.2.3 (br-frankenpandas-kmy0b): bfill -> [1, 3, 3], bfill(limit=1) -> [1, NaN, 3].

Source

pub fn fillna( &self, method: &str, limit: Option<usize>, ) -> Result<Series, FrameError>

Fill missing resampled values by upsampling (pad/ffill, backfill/bfill, or nearest).

Source

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

Interpolate missing values after upsampling (asfreq) to bucket edges.

Source

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

pandas’ Resampler.nearest(limit): each bin edge takes the row nearest to it (a tie to the later one), limit bounding the inexact matches on each side (see Self::upsample). It returned first() - NaN at every edge without a row in its bin (br-frankenpandas-rc0923-epic-rust-parity-bugs-4qg5w.4).

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> !RefUnwindSafe for Resample<'a>

§

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

§

impl<'a> Forget for Resample<'a>

§

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

§

impl<'a> Move 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>

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more