-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
REF: simplify DTI._parse_string_to_bounds #31519
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
REF: simplify DTI._parse_string_to_bounds #31519
Conversation
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.
minor test nit otherwise lgtm
pandas/_libs/tslibs/period.pyx
Outdated
@@ -1186,6 +1186,13 @@ cdef int64_t period_ordinal_to_dt64(int64_t ordinal, int freq) except? -1: | |||
if ordinal == NPY_NAT: | |||
return NPY_NAT | |||
|
|||
if freq == 11000: | |||
# Microsecond, avoid get_date_info to prevent floating point errors | |||
pandas_datetime_to_datetimestruct(ordinal, NPY_FR_us, &dts) |
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.
unrelated but have you ever thought about renaming this function to something like "int64ns_to_datetimestruct"? I always find myself thinking about what a "pandas_datetime" is
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 generally agree. i think it got this name because the numpy version is numpy_datetime_to_datetimestruct or something along those lines.
assert start == expected | ||
assert start.value == per.ordinal * 1000 | ||
|
||
per2 = Period("2300-01-01", "us") |
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.
Can you split this off into a separate _raises
test?
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.
sure
…rsed_string_to_bounds
…rsed_string_to_bounds
nice, really simplfies |
Sits on top of #31475. i.e. once that is merged, the only diff remaining here will be in indexes.datetimes.
After this, we are within striking distance of sharing the method between DTI/PI.