-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: can't round-trip non-nano Timestamp #51087
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
BUG: can't round-trip non-nano Timestamp #51087
Conversation
elif reso == NPY_DATETIMEUNIT.NPY_FR_M: | ||
# 2629746 comes from dividing the "Y" case by 12. | ||
m = 1_000_000_000 * 2629746 | ||
p = 9 | ||
m = multiplier * 2629746 |
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'm pretty sure the M and Y cases in precision_from_unit are no longer reached, in which case the entire m
part of this function i think can be replaced with get_conversion_factor
(OK to consider out of scope)
This reverts commit 27fd951.
pandas/_libs/tslibs/conversion.pyx
Outdated
@@ -294,9 +296,15 @@ cdef _TSObject convert_to_tsobject(object ts, tzinfo tz, str unit, | |||
if ts == NPY_NAT: | |||
obj.value = NPY_NAT | |||
else: | |||
ts = cast_from_unit(ts, unit) | |||
if unit is None: | |||
in_reso = abbrev_to_npy_unit("ns") |
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.
should we assign unit="ns" here since we pass it to cast_from_unit below?
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.
OK for follow-up
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.
yup, good one, thanks
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.
LGTM, one comment for a follow-up
Thanks for your review! |
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.This should fix the interger case, but not the float one, so let's still keep the issue open for now