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

Raise NotImplementedError for Categoricals with timezones #14032

Merged

Conversation

mroeschke
Copy link
Contributor

@mroeschke mroeschke commented Sep 1, 2023

Description

Currently cudf.from_pandas with a pandas Categorical with datetimetz type will drop the timezone information (due to pyarrow)

In [5]: import pandas as pd

In [6]: ci = pd.CategoricalIndex(pd.date_range("2016-01-01 01:01:00", periods=5, freq="D").tz_localize("UTC"))

In [7]: ci
Out[7]: 
CategoricalIndex(['2016-01-01 01:01:00+00:00', '2016-01-02 01:01:00+00:00',
                  '2016-01-03 01:01:00+00:00', '2016-01-04 01:01:00+00:00',
                  '2016-01-05 01:01:00+00:00'],
                 categories=[2016-01-01 01:01:00+00:00, 2016-01-02 01:01:00+00:00, 2016-01-03 01:01:00+00:00, 2016-01-04 01:01:00+00:00, 2016-01-05 01:01:00+00:00], ordered=False, dtype='category')

In [8]: ci_cudf = cudf.from_pandas(ci)

In [10]: ci_cudf
Out[10]: 
CategoricalIndex(['2016-01-01 01:01:00', '2016-01-02 01:01:00',
                  '2016-01-03 01:01:00', '2016-01-04 01:01:00',
                  '2016-01-05 01:01:00'],
                 categories=[2016-01-01 01:01:00, 2016-01-02 01:01:00, 2016-01-03 01:01:00, 2016-01-04 01:01:00, 2016-01-05 01:01:00], ordered=False, dtype='category')

Like what is done with IntervalIndex, raises a NotImplementedError for now to avoid this wrong behavior.

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@mroeschke mroeschke requested a review from a team as a code owner September 1, 2023 21:38
@github-actions github-actions bot added the Python Affects Python cuDF API. label Sep 1, 2023
@mroeschke mroeschke added bug Something isn't working non-breaking Non-breaking change labels Sep 1, 2023
Copy link
Contributor

@wence- wence- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@wence-
Copy link
Contributor

wence- commented Sep 4, 2023

/merge

@rapids-bot rapids-bot bot merged commit 3e5f019 into rapidsai:branch-23.10 Sep 4, 2023
55 checks passed
@mroeschke mroeschke deleted the py/cat_tz/notimplemented branch September 5, 2023 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working non-breaking Non-breaking change Python Affects Python cuDF API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants