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 in to_datetime if Z (or tz component) in string #14074

Merged
merged 7 commits into from
Sep 14, 2023

Conversation

mroeschke
Copy link
Contributor

@mroeschke mroeschke commented Sep 8, 2023

Description

closes #14039
Avoids this discrepancy when a date string has a tz component

In [1]: import pandas

In [2]: import cudf

In [3]: data = ["2019-01-01T00:00:00.000Z"]

In [4]: cudf.to_datetime(data)
Out[4]: DatetimeIndex(['2019-01-01'], dtype='datetime64[ns]')

In [5]: pandas.to_datetime(data)
Out[5]: DatetimeIndex(['2019-01-01 00:00:00+00:00'], dtype='datetime64[ns, UTC]', freq=None)

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 8, 2023 21:51
@github-actions github-actions bot added the Python Affects Python cuDF API. label Sep 8, 2023
@mroeschke mroeschke added bug Something isn't working non-breaking Non-breaking change labels Sep 8, 2023
Copy link
Contributor

@vyasr vyasr left a comment

Choose a reason for hiding this comment

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

Looks like this broke some other tests that were expecting this to work, those need updating as well.

@@ -1278,12 +1278,8 @@ def test_datetime_reductions(data, op, dtype):
@pytest.mark.parametrize("dtype", DATETIME_TYPES)
def test_datetime_infer_format(data, dtype):
Copy link
Contributor

Choose a reason for hiding this comment

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

This test verifies if our string-to-time conversions work properly until nano-second time resolution. Can you add another set of tests that drop the timezone="UTC" parameter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I'll add back that testing in this test

@mroeschke
Copy link
Contributor Author

/merge

@rapids-bot rapids-bot bot merged commit 664dfc3 into rapidsai:branch-23.10 Sep 14, 2023
54 checks passed
@mroeschke mroeschke deleted the bug/to_datetime/z branch September 15, 2023 20:02
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.

[BUG] cudf.to_datetime with arg with Z drops UTC offset incorrectly
3 participants