[X] I have checked that this issue has not already been reported.
[X] I have confirmed this bug exists on the latest version of Polars.
Reproducible example
from datetime import datetime
import polars as pl
df = pl.DataFrame().with_columns(
pl.datetime_range(datetime(2024, 7, 18), datetime(2024, 7, 19), '15m').alias(
'datetime'
)
)
print(df['datetime'].min())
df = df.with_columns(pl.col('datetime').dt.replace_time_zone('UTC'))
print(df['datetime'].min())
>>> 2024-07-18 00:00:00
>>> thread '<unnamed>' panicked at py-polars\src\conversion\any_value.rs:84:22:
>>> called `Result::unwrap()` on an `Err` value: PyErr { type: <class 'ValueError'>, value: ValueError("unexpected time zone offset: 'Europe/London'"), traceback: Some(<traceback object at 0x00000144BF81DB80>) }
>>> note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
>>> Traceback (most recent call last):
>>> File "D:\code\river-level-analysis\hydro-api\tests\polars_bug.py", line 15, in <module>
>>> print(df['datetime'].min())
>>> ^^^^^^^^^^^^^^^^^^^^
>>> File "D:\code\river-level-analysis\hydro-api\.venv\Lib\site-packages\polars\series\series.py", line 1980, in min
>>> return self._s.min()
>>> ^^^^^^^^^^^^^
>>> pyo3_runtime.PanicException: called `Result::unwrap()` on an `Err` value: PyErr { type: <class 'ValueError'>, value: ValueError("unexpected time zone offset: 'Europe/London'"), traceback: Some(<traceback object at 0x00000144BF81DB80>) }
Log output
thread '<unnamed>' panicked at py-polars\src\conversion\any_value.rs:84:22:
called `Result::unwrap()` on an `Err` value: PyErr { type: <class 'ValueError'>, value: ValueError("unexpected time zone offset: 'UTC'"), traceback: Some(<traceback object at 0x000002249D6ADBC0>) }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Traceback (most recent call last):
File "D:\code\river-level-analysis\hydro-api\tests\polars_bug.py", line 15, in <module>
print(df['datetime'].min())
^^^^^^^^^^^^^^^^^^^^
File "D:\code\river-level-analysis\hydro-api\.venv\Lib\site-packages\polars\series\series.py", line 1980, in min
return self._s.min()
^^^^^^^^^^^^^
pyo3_runtime.PanicException: called `Result::unwrap()` on an `Err` value: PyErr { type: <class 'ValueError'>, value: ValueError("unexpected time zone offset: 'UTC'"), traceback: Some(<traceback object at 0x000002249D6ADBC0>) }
Issue description
This appears to happen with other timezones as well, not just UTC. E.g. Europe/London also produced the same error.
Expected behavior
Should not panic and should return a timezone aware datetime like: 2024-07-18 00:00:00+00:00
Checks
Reproducible example
Log output
Issue description
This appears to happen with other timezones as well, not just UTC. E.g. Europe/London also produced the same error.
Expected behavior
Should not panic and should return a timezone aware datetime like: 2024-07-18 00:00:00+00:00
Installed versions