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

Cleanup some timedelta/datetime column logic #14715

Merged
merged 35 commits into from
Apr 5, 2024

Conversation

mroeschke
Copy link
Contributor

Description

Remove private _time_unit attribute in favor of the public one and perform dtype validation earlier in __init__

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 added Python Affects Python cuDF API. improvement Improvement / enhancement to an existing function non-breaking Non-breaking change labels Jan 6, 2024
@mroeschke mroeschke requested a review from a team as a code owner January 6, 2024 00:13
def __contains__(self, item: ScalarLike) -> bool:
try:
item_as_dt64 = np.datetime64(item, self._time_unit)
item_as_dt64 = np.datetime64(item, self.time_unit)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit If self.dtype is a DatetimeTZDtype is this code correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good find, no it doesn't. In pandas least for DatetimeTZDtype, item must be tz-aware and the same UTC time to return True.

In [1]: import pandas as pd

In [2]: dti = pd.date_range("2020", periods=3, tz="UTC")

In [3]: pd.Timestamp("2020") in dti
Out[3]: False

In [4]: pd.Timestamp("2020", tz="UTC") in dti
Out[4]: True

In [5]: pd.Timestamp("2020", tz="US/Pacific") in dti
Out[5]: False

In [6]: pd.Timestamp("2019-12-31T16:00:00", tz="US/Pacific") in dti
Out[6]: True

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed this case and added a unit test

python/cudf/cudf/core/_internals/timezones.py Show resolved Hide resolved
python/cudf/cudf/core/column/timedelta.py Show resolved Hide resolved
python/cudf/cudf/core/column/timedelta.py Show resolved Hide resolved
@mroeschke mroeschke requested a review from wence- January 19, 2024 22:07
@vyasr
Copy link
Contributor

vyasr commented Jan 23, 2024

@wence- could you take another look at this PR?

@mroeschke mroeschke changed the base branch from branch-24.02 to branch-24.04 January 31, 2024 21:37
@mroeschke
Copy link
Contributor Author

@wence- when you have a moment could you re-review this PR?

@mroeschke mroeschke changed the base branch from branch-24.04 to branch-24.06 March 18, 2024 22:05
Copy link
Contributor

@shwina shwina left a comment

Choose a reason for hiding this comment

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

Some really nice cleanups here. Thanks!

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 Apr 5, 2024

/merge

@rapids-bot rapids-bot bot merged commit a00c3c9 into rapidsai:branch-24.06 Apr 5, 2024
69 checks passed
@mroeschke mroeschke deleted the ref/column/cleanups branch April 5, 2024 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Improvement / enhancement to an existing function non-breaking Non-breaking change Python Affects Python cuDF API.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants