-
Notifications
You must be signed in to change notification settings - Fork 915
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 error when trying to construct time-zone aware timestamps #13830
Conversation
Co-authored-by: Ashwin Srinath <[email protected]>
other = other.to_datetime64() | ||
elif isinstance(other, pd.Timedelta): | ||
other = other.to_timedelta64() | ||
elif isinstance(other, datetime.datetime): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about TZ-aware datetime.datetime
objects? e.g.
>>> import datetime
>>> datetime.datetime.now(datetime.timezone.utc)
datetime.datetime(2023, 8, 7, 20, 47, 48, 483493, tzinfo=datetime.timezone.utc)
Do those need to error, too? On conversion to np.datetime64
, I get a warning. Is that sufficient?
>>> np.datetime64(datetime.datetime(2023, 8, 7, 20, 47, 48, 483493, tzinfo=datetime.timezone.utc))
<stdin>:1: DeprecationWarning: parsing timezone aware datetimes is deprecated; this will raise an error in the future
numpy.datetime64('2023-08-07T20:47:48.483493')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should raise for it too. Good catch, I thought datetime
was tz agnostic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bdice I updated the code to handle datetime.datetime
objects aswell.
/merge |
Description
Fixes: #13825 This PR raises an error when a time-zone-aware scalar is passed to binops or cudf scalar construction.
Checklist