Trait polars_time::PolarsUpsample

source ·
pub trait PolarsUpsample {
    // Required methods
    fn upsample<I: IntoVec<String>>(
        &self,
        by: I,
        time_column: &str,
        every: Duration
    ) -> PolarsResult<DataFrame>;
    fn upsample_stable<I: IntoVec<String>>(
        &self,
        by: I,
        time_column: &str,
        every: Duration
    ) -> PolarsResult<DataFrame>;
}

Required Methods§

source

fn upsample<I: IntoVec<String>>( &self, by: I, time_column: &str, every: Duration ) -> PolarsResult<DataFrame>

Upsample a DataFrame at a regular frequency.

§Arguments
  • by - First group by these columns and then upsample for every group
  • time_column - Will be used to determine a date_range. Note that this column has to be sorted for the output to make sense.
  • every - interval will start ‘every’ duration
  • offset - change the start of the date_range by this offset.

The every and offset arguments are created with the following string language:

  • 1ns (1 nanosecond)
  • 1us (1 microsecond)
  • 1ms (1 millisecond)
  • 1s (1 second)
  • 1m (1 minute)
  • 1h (1 hour)
  • 1d (1 calendar day)
  • 1w (1 calendar week)
  • 1mo (1 calendar month)
  • 1q (1 calendar quarter)
  • 1y (1 calendar year)
  • 1i (1 index count)

Or combine them: “3d12h4m25s” # 3 days, 12 hours, 4 minutes, and 25 seconds

By “calendar day”, we mean the corresponding time on the next day (which may not be 24 hours, depending on daylight savings). Similarly for “calendar week”, “calendar month”, “calendar quarter”, and “calendar year”.

source

fn upsample_stable<I: IntoVec<String>>( &self, by: I, time_column: &str, every: Duration ) -> PolarsResult<DataFrame>

Upsample a DataFrame at a regular frequency.

Similar to upsample, but order of the DataFrame is maintained when by is specified.

§Arguments
  • by - First group by these columns and then upsample for every group
  • time_column - Will be used to determine a date_range. Note that this column has to be sorted for the output to make sense.
  • every - interval will start ‘every’ duration
  • offset - change the start of the date_range by this offset.

The every and offset arguments are created with the following string language:

  • 1ns (1 nanosecond)
  • 1us (1 microsecond)
  • 1ms (1 millisecond)
  • 1s (1 second)
  • 1m (1 minute)
  • 1h (1 hour)
  • 1d (1 calendar day)
  • 1w (1 calendar week)
  • 1mo (1 calendar month)
  • 1q (1 calendar quarter)
  • 1y (1 calendar year)
  • 1i (1 index count)

Or combine them: “3d12h4m25s” # 3 days, 12 hours, 4 minutes, and 25 seconds

By “calendar day”, we mean the corresponding time on the next day (which may not be 24 hours, depending on daylight savings). Similarly for “calendar week”, “calendar month”, “calendar quarter”, and “calendar year”.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl PolarsUpsample for DataFrame

source§

fn upsample<I: IntoVec<String>>( &self, by: I, time_column: &str, every: Duration ) -> PolarsResult<DataFrame>

source§

fn upsample_stable<I: IntoVec<String>>( &self, by: I, time_column: &str, every: Duration ) -> PolarsResult<DataFrame>

Implementors§