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 return incorrect results for pre-1970 dates #17581

Closed
2 tasks done
MarcoGorelli opened this issue Jul 11, 2024 · 1 comment · Fixed by #17582
Closed
2 tasks done

.dt.truncate may return incorrect results for pre-1970 dates #17581

MarcoGorelli opened this issue Jul 11, 2024 · 1 comment · Fixed by #17582
Assignees
Labels
bug Something isn't working P-high Priority: high python Related to Python Polars

Comments

@MarcoGorelli
Copy link
Collaborator

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

In [26]: In [1]: import polars as pl
    ...:
    ...: In [2]: from datetime import date, datetime
    ...:
    ...: In [3]: s = pl.Series([datetime(1980, 1, 1), datetime(1969,1,1,1)])
    ...:
    ...: In [4]: s.dt.truncate('1d')
Out[26]:
shape: (2,)
Series: '' [datetime[μs]]
[
        1980-01-01 00:00:00
        1969-01-03 00:00:00
]

Log output

No response

Issue description

the second one is wrong

Expected behavior

shape: (2,)
Series: '' [datetime[μs]]
[
        1980-01-01 00:00:00
        1969-01-01 00:00:00
]

Installed versions

--------Version info---------
Polars:               1.1.0
Index type:           UInt32
Platform:             Linux-5.15.153.1-microsoft-standard-WSL2-x86_64-with-glibc2.35
Python:               3.11.9 (main, Apr  6 2024, 17:59:24) [GCC 11.4.0]

----Optional dependencies----
adbc_driver_manager:  <not installed>
cloudpickle:          3.0.0
connectorx:           <not installed>
deltalake:            <not installed>
fastexcel:            <not installed>
fsspec:               2024.3.1
gevent:               <not installed>
great_tables:         0.7.0
hvplot:               0.10.0
matplotlib:           3.8.4
nest_asyncio:         1.6.0
numpy:                1.26.4
openpyxl:             <not installed>
pandas:               2.2.2
pyarrow:              16.1.0
pydantic:             <not installed>
pyiceberg:            <not installed>
sqlalchemy:           <not installed>
torch:                <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 labels Jul 11, 2024
@MarcoGorelli
Copy link
Collaborator Author

Noticed this while writing a hypothesis test

fix incoming

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-high Priority: high python Related to Python Polars
Projects
Archived in project
1 participant