-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Open
Labels
P-mediumPriority: mediumPriority: mediumacceptedReady for implementationReady for implementationbugSomething isn't workingSomething isn't workingpythonRelated to Python PolarsRelated to Python Polars
Description
Checks
- I have checked that this issue has not already been reported.
- I have confirmed this bug exists on the latest version of Polars.
Reproducible example
import polars as pl
import datetime as dt
df = pl.DataFrame({"timestamp": pl.datetime_range(dt.datetime(2024,2,7,9,31), dt.datetime(2024,2, 24, 16,0), time_zone="America/New_York", eager=True, interval="1m")}).join(pl.DataFrame({"id":[1,2,3]}), how="cross")
df.group_by_dynamic("timestamp", every="1m", period=dt.timedelta(days=17), closed="both", label="left", group_by="id").agg(ts_last=pl.col("timestamp").last())
# error: thread ‘polars-0’ panicked at crates/polars-time/src/windows/window.rs:334:86:
# pyo3_runtime.PanicException: called `Result::unwrap()` on an `Err` value: ComputeError(ErrString("datetime '2024-03-10 02:00:00' is non-existent in time zone 'America/New_York'. You may be able to use `non_existent='null'` to return `null` in this case."))
# even if we filter out the daylight savings transition period, we still get the same panic
df = df.filter(pl.col("timestamp").dt.hour().is_between(9,16))
Log output
Issue description
group_by_dynamic will panic when the start/end of the window passes over an ambiguous/non-existent datetime. This will happen even if the datetime column does not include ambiguous/non-existent datetimes.
Expected behavior
group_by_dynamic should be able to handle daylight savings. Or at least skip over the problematic period if it doesn’t show up in the original DataFrame.
Installed versions
Replace this line with the output of pl.show_versions(). Leave the backticks in place.
Metadata
Metadata
Assignees
Labels
P-mediumPriority: mediumPriority: mediumacceptedReady for implementationReady for implementationbugSomething isn't workingSomething isn't workingpythonRelated to Python PolarsRelated to Python Polars