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

DateTime type lost after unique() inside GroupBy Context #9856

Closed
2 tasks done
0xbe7a opened this issue Jul 13, 2023 · 0 comments · Fixed by #9886
Closed
2 tasks done

DateTime type lost after unique() inside GroupBy Context #9856

0xbe7a opened this issue Jul 13, 2023 · 0 comments · Fixed by #9886
Labels
bug Something isn't working python Related to Python Polars

Comments

@0xbe7a
Copy link
Contributor

0xbe7a commented Jul 13, 2023

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 date, timedelta

df = pl.DataFrame(
    {
        "key": ["A", "A", "A", "A"],
        "dates": [date(1970, 1, 1), date(1970, 1, 1), date(1970, 1, 2), date(1970, 1, 3)],
    }
)

# BROKEN
# output [86400000000, 86400000001, 86400000002]
df.groupby("key").agg(pl.col("dates").unique() + timedelta(days=1))



# WORKS
# output [1970-01-02, 1970-01-03, 1970-01-04]
df.groupby("key").agg((pl.col("dates") + timedelta(days=1)).unique())

Issue description

When adding a timedelta to a deduplicated column inside a "GroupBy" context the type is lost and the output has type 'Int64'

Expected behavior

The output type should be 'Date'

Installed versions

--------Version info---------
Polars:              0.18.7
Index type:          UInt32
Platform:            macOS-13.3.1-arm64-arm-64bit
Python:              3.11.4 | packaged by conda-forge | (main, Jun 10 2023, 18:08:41) [Clang 15.0.7 ]

----Optional dependencies----
adbc_driver_sqlite:  <not installed>
connectorx:          <not installed>
deltalake:           <not installed>
fsspec:              <not installed>
matplotlib:          <not installed>
numpy:               1.25.0
pandas:              <not installed>
pyarrow:             <not installed>
pydantic:            <not installed>
sqlalchemy:          <not installed>
xlsx2csv:            <not installed>
xlsxwriter:          <not installed>
@0xbe7a 0xbe7a added bug Something isn't working python Related to Python Polars labels Jul 13, 2023
@github-project-automation github-project-automation bot moved this to Untriaged in Backlog Jul 13, 2023
@0xbe7a 0xbe7a changed the title DateTime Type lost after unique() inside Groupby Context DateTime Type lost after unique() inside GroupBy Context Jul 13, 2023
@0xbe7a 0xbe7a changed the title DateTime Type lost after unique() inside GroupBy Context DateTime type lost after unique() inside GroupBy Context Jul 13, 2023
@stinodego stinodego removed this from Backlog Jul 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working python Related to Python Polars
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant