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

Cannot extract Time from DateTime before Unix epoch #13801

Closed
2 tasks done
jeroenjanssens opened this issue Jan 18, 2024 · 2 comments · Fixed by #13812
Closed
2 tasks done

Cannot extract Time from DateTime before Unix epoch #13801

jeroenjanssens opened this issue Jan 18, 2024 · 2 comments · Fixed by #13812
Assignees
Labels
A-timeseries Area: date/time functionality bug Something isn't working P-medium Priority: medium python Related to Python Polars

Comments

@jeroenjanssens
Copy link
Contributor

jeroenjanssens commented Jan 18, 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

pl.select(pl.datetime(1969, 7, 21, 2, 56, 0).dt.time()) # Man on the moon 

Log output

$ POLARS_VERBOSE=1 poetry run python -c "import polars as pl; print(pl.select(pl.datetime(1969, 7, 21, 2, 56, 0).dt.time()))"
thread '<unnamed>' panicked at /Users/runner/work/polars/polars/crates/polars-arrow/src/temporal_conversions.rs:130:29:
invalid time
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/jeroen/Library/Caches/pypoetry/virtualenvs/python-polars-the-definitive-guide-b_q50VVY-py3.11/lib/python3.11/site-packages/polars/dataframe/frame.py", line 1570, in __str__
    return self._df.as_str()
           ^^^^^^^^^^^^^^^^^
pyo3_runtime.PanicException: invalid time

Issue description

Cannot extract Time component from a DateTime before Unix epoch (1970-01-01).

Expected behavior

Output should be the same as for a DateTime after Unix epoch:

shape: (1, 1)
┌──────────┐
│ datetime │
│ ---      │
│ time     │
╞══════════╡
│ 02:56:00 │
└──────────┘

Installed versions

--------Version info---------
Polars:               0.20.4
Index type:           UInt32
Platform:             macOS-12.5-arm64-arm-64bit
Python:               3.11.6 (main, Nov  2 2023, 04:39:40) [Clang 14.0.0 (clang-1400.0.29.202)]

----Optional dependencies----
adbc_driver_manager:  0.8.0
cloudpickle:          3.0.0
connectorx:           0.3.2
deltalake:            0.15.0
fsspec:               2023.12.2
gevent:               23.9.1
hvplot:               <not installed>
matplotlib:           3.8.2
numpy:                1.26.3
openpyxl:             3.1.2
pandas:               2.1.4
pyarrow:              14.0.2
pydantic:             2.5.3
pyiceberg:            0.5.1
pyxlsb:               <not installed>
sqlalchemy:           2.0.25
xlsx2csv:             0.8.2
xlsxwriter:           3.1.9
@jeroenjanssens jeroenjanssens added bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars labels Jan 18, 2024
@MarcoGorelli MarcoGorelli added A-timeseries Area: date/time functionality and removed needs triage Awaiting prioritization by a maintainer labels Jan 18, 2024
@MarcoGorelli
Copy link
Collaborator

thanks for the report, taking a look

@MarcoGorelli MarcoGorelli self-assigned this Jan 18, 2024
@MarcoGorelli MarcoGorelli added the accepted Ready for implementation label Jan 18, 2024
@MarcoGorelli
Copy link
Collaborator

pl.select(pl.datetime(1969, 7, 21, 2, 56, 0).dt.time()) # Man on the moon

"they can put a man on the moon, and still they can't..." https://youtu.be/3Eo2uq5k1O0?si=ugAA7axadVBiXVDb


fix incoming

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-timeseries Area: date/time functionality bug Something isn't working P-medium Priority: medium python Related to Python Polars
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants