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

Cast from pl.Date to pl.Datetime silently returns incorrect value when new dtype cannot hold value #16039

Open
2 tasks done
mcrumiller opened this issue May 3, 2024 · 2 comments
Labels
A-timeseries Area: date/time functionality bug Something isn't working P-medium Priority: medium python Related to Python Polars

Comments

@mcrumiller
Copy link
Contributor

mcrumiller commented May 3, 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

When attempting to cast pl.Date to pl.Datetime("ns"), the date changes, when perhaps we should raise instead:

from datetime import date
import polars as pl

# lower date limit for nanosecond
pl.Series([date(1677, 9, 22)]).cast(pl.Datetime("ns")) # 1677-09-22 00:00:00
pl.Series([date(1677, 9, 21)]).cast(pl.Datetime("ns")) # 2262-04-11 23:34:33.709551616

# upper date limit for nanosecond
pl.Series([date(2262, 4, 11)]).cast(pl.Datetime("ns"))  # 2262-04-11 00:00:00
pl.Series([date(2262, 4, 12)]).cast(pl.Datetime("ns"))  # 1677-09-21 00:25:26.290448384

Installed versions

main
@mcrumiller mcrumiller added bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars labels May 3, 2024
@mcrumiller
Copy link
Contributor Author

@MarcoGorelli

@MarcoGorelli MarcoGorelli added A-timeseries Area: date/time functionality P-medium Priority: medium and removed needs triage Awaiting prioritization by a maintainer labels May 3, 2024
@MarcoGorelli
Copy link
Collaborator

thanks for the ping

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
Status: Ready
Development

No branches or pull requests

2 participants