Sha256: 5e3f5e8ef3dd2fa44dbcf46f87430367772d0a9392624582d6a03493a685ab03

Contents?: true

Size: 1.16 KB

Versions: 3

Compression:

Stored size: 1.16 KB

Contents

use polars::lazy::dsl;
use polars_core::datatypes::{TimeUnit, TimeZone};

use crate::conversion::Wrap;
use crate::prelude::*;
use crate::RbExpr;

pub fn int_range(start: &RbExpr, end: &RbExpr, step: i64, dtype: Wrap<DataType>) -> RbExpr {
    let start = start.inner.clone();
    let end = end.inner.clone();
    let dtype = dtype.0;
    dsl::int_range(start, end, step, dtype).into()
}

pub fn int_ranges(start: &RbExpr, end: &RbExpr, step: &RbExpr, dtype: Wrap<DataType>) -> RbExpr {
    let dtype = dtype.0;

    let mut result = dsl::int_ranges(start.inner.clone(), end.inner.clone(), step.inner.clone());

    if dtype != DataType::Int64 {
        result = result.cast(DataType::List(Box::new(dtype)))
    }

    result.into()
}

pub fn date_range(
    start: &RbExpr,
    end: &RbExpr,
    every: String,
    closed: Wrap<ClosedWindow>,
    time_unit: Option<Wrap<TimeUnit>>,
    time_zone: Option<TimeZone>,
) -> RbExpr {
    let start = start.inner.clone();
    let end = end.inner.clone();
    let every = Duration::parse(&every);
    let closed = closed.0;
    let time_unit = time_unit.map(|x| x.0);
    dsl::date_range(start, end, every, closed, time_unit, time_zone).into()
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
polars-df-0.10.0 ext/polars/src/functions/range.rs
polars-df-0.9.0 ext/polars/src/functions/range.rs
polars-df-0.8.0 ext/polars/src/functions/range.rs