Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dt.truncate may panic on non-existent datetimes #14957

Closed
2 tasks done
MarcoGorelli opened this issue Mar 10, 2024 · 0 comments · Fixed by #14958
Closed
2 tasks done

dt.truncate may panic on non-existent datetimes #14957

MarcoGorelli opened this issue Mar 10, 2024 · 0 comments · Fixed by #14958
Assignees
Labels
bug Something isn't working P-low Priority: low python Related to Python Polars

Comments

@MarcoGorelli
Copy link
Collaborator

MarcoGorelli commented Mar 10, 2024

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
from datetime import datetime

pl.Series([datetime(2020, 3, 29, 2, 1)]).dt.replace_time_zone('Europe/London').dt.truncate('46m')

Log output

thread '<unnamed>' panicked at crates/polars-time/src/windows/duration.rs:468:85:
called `Result::unwrap()` on an `Err` value: ComputeError(ErrString("datetime '2020-03-29 01:42:00' is non-existent in time zone 'Europe/London'. Non-existent datetimes are not yet supported"))
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Traceback (most recent call last):
  File "/home/marcogorelli/scratch/t.py", line 4, in <module>
    pl.Series([datetime(2020, 3, 29, 2, 1)]).dt.replace_time_zone('Europe/London').dt.truncate('46m')
  File "/home/marcogorelli/scratch/.venv/lib/python3.11/site-packages/polars/series/utils.py", line 107, in wrapper
    return s.to_frame().select_seq(f(*args, **kwargs)).to_series()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/marcogorelli/scratch/.venv/lib/python3.11/site-packages/polars/dataframe/frame.py", line 8141, in select_seq
    return self.lazy().select_seq(*exprs, **named_exprs).collect(_eager=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/marcogorelli/scratch/.venv/lib/python3.11/site-packages/polars/lazyframe/frame.py", line 1934, in collect
    return wrap_df(ldf.collect())
                   ^^^^^^^^^^^^^
pyo3_runtime.PanicException: called `Result::unwrap()` on an `Err` value: ComputeError(ErrString("datetime '2020-03-29 01:42:00' is non-existent in time zone 'Europe/London'. Non-existent datetimes are not yet supported"))

Issue description

this should raise a proper error

Expected behavior

this should raise a proper error

Installed versions

--------Version info---------
Polars:               0.20.14
Index type:           UInt32
Platform:             Linux-5.15.146.1-microsoft-standard-WSL2-x86_64-with-glibc2.35
Python:               3.11.7 (main, Dec  8 2023, 18:56:58) [GCC 11.4.0]

----Optional dependencies----
adbc_driver_manager:  <not installed>
cloudpickle:          <not installed>
connectorx:           <not installed>
deltalake:            <not installed>
fastexcel:            <not installed>
fsspec:               <not installed>
gevent:               <not installed>
hvplot:               0.9.2
matplotlib:           <not installed>
numpy:                1.26.4
openpyxl:             <not installed>
pandas:               2.1.0
pyarrow:              15.0.0
pydantic:             2.6.1
pyiceberg:            <not installed>
pyxlsb:               <not installed>
sqlalchemy:           <not installed>
xlsx2csv:             <not installed>
xlsxwriter:           <not installed>
@MarcoGorelli MarcoGorelli added bug Something isn't working python Related to Python Polars needs triage Awaiting prioritization by a maintainer P-low Priority: low and removed needs triage Awaiting prioritization by a maintainer labels Mar 10, 2024
@MarcoGorelli MarcoGorelli self-assigned this Mar 10, 2024
@github-project-automation github-project-automation bot moved this to Ready in Backlog Mar 10, 2024
@github-project-automation github-project-automation bot moved this from Ready to Done in Backlog Mar 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P-low Priority: low python Related to Python Polars
Projects
Archived in project
1 participant