-
Notifications
You must be signed in to change notification settings - Fork 912
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 to_datetime with z format #14037
Conversation
def test_format_timezone_not_implemented(code): | ||
with pytest.raises(NotImplementedError): | ||
cudf.to_datetime( | ||
["2020-01-01 00:00:00 UTC"], format=f"%Y-%m-%d %H-%M-%S %{code}" |
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.
["2020-01-01 00:00:00 UTC"], format=f"%Y-%m-%d %H-%M-%S %{code}" | |
["2020-01-01 00:00:00 UTC"], format=f"%Y-%m-%d %H:%M:%S %{code}" |
Format string doesn't match the provided date string without it (and once timezones are implemented, we would expect this test to raise ValueError
because of it).
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.
Thanks for the catch
if "%Z" in format or "%z" in format: | ||
raise NotImplementedError( | ||
"cuDF does not yet support timezone-aware datetimes" | ||
) | ||
elif "%f" in format: | ||
format = format.replace("%f", "%9f") |
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.
Note: This is fine, but I'll just note that %%Z
is a valid string for strptime
that means "look for a literal %Z
". So this replacement (and the existing %f
replacement) is not robust against some of the wackier formats a user might provide.
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.
Thanks @mroeschke
/merge |
Description
Avoids timezone information from being dropped in
to_datetime
when the z directive is providedChecklist