• Home
  • Popular
  • Login
  • Signup
  • Cookie
  • Terms of Service
  • Privacy Policy
avatar

Posted by John Dev


10 Jan, 2025

Updated at 20 Jan, 2025

Cannot find datetime_ranges function in Polars despite matching documentation

I'm trying to use the datetime_ranges function from Polars as shown in their documentation, but I'm running into compilation issues:

According to the docs, this function should be available when using the lazy and dtype-datetime features:

pub fn datetime_ranges(
    start: Expr,
    end: Expr,
    interval: Duration,
    closed: ClosedWindow,
    time_unit: Option<TimeUnit>,
    time_zone: Option<TimeZone>,
) -> Expr

Here's my current setup:

// Dependencies in Cargo.toml
polars = {version="0.45.1", features = ["lazy", "dtype-datetime", "parquet", "is_in", "polars-io", "strings", "round_series", "polars-ops", "temporal", "offset_by", "dtype-array","concat_str", "asof_join", "cross_join"]}

// In my code
use polars::lazy::dsl::*;
use polars::prelude::*;

// Trying to use it like this:
let windows: LazyFrame = windows.with_column(datetime_ranges(
    col("window_start_min"),
    col("window_end_max"),
    granularity,
    ClosedWindow::Both,
    TimeUnit::Milliseconds,
    None,
));

However, I'm getting the error:

cannot find function datetime_ranges in this scope

And when trying to explicitly import it:

unresolved import polars::prelude::datetime_ranges
no datetime_ranges in prelude

What am I missing here?

5 posts - 3 participants

Read full topic