-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Timedelta components no longer rounded with high precision integers #31380
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -859,14 +859,6 @@ cdef class _Timedelta(timedelta): | |
""" | ||
return self.to_timedelta64() | ||
|
||
def total_seconds(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No longer need this implementation since we can rely on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what change for the "no longer" part? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we are now dispatching the correct microseconds to we can use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sounds good, thanks for explaining There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FWIW, I did consider suggesting the removal of |
||
""" | ||
Total duration of timedelta in seconds (to microsecond precision). | ||
""" | ||
# GH 31043 | ||
# Microseconds precision to avoid confusing tzinfo.utcoffset | ||
return (self.value - self.value % 1000) / 1e9 | ||
|
||
def view(self, dtype): | ||
""" | ||
Array view compatibility. | ||
|
@@ -1250,7 +1242,7 @@ class Timedelta(_Timedelta): | |
return NaT | ||
|
||
# make timedelta happy | ||
td_base = _Timedelta.__new__(cls, microseconds=int(value) / 1000) | ||
td_base = _Timedelta.__new__(cls, microseconds=int(value) // 1000) | ||
td_base.value = value | ||
td_base.is_populated = 0 | ||
return td_base | ||
|
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.
BTW, I'm not sure if it was already covered by the earlier PR, but it seems like the change in precision to
total_seconds()
from "dubiously nanosecond-precision" to "microsecond-precision" should probably show up in the release notes. It seems like this is the only entry underTimedelta
, so maybe it was done silently? Or was the other change already released?