-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: Fix total seconds in timedelta #45129
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
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.
needs a test case
also some tests are failing |
Yes, I referred that in the entry PR message. I could not figure out what the reason is and I am lacking the time to further seek the source. Maybe somebody already knows the issue or could help? cc @mroeschke |
This comment might potentially be relevant https://github.com/pandas-dev/pandas/pull/31155/files#r370721655 |
…ity reasons DOC: updated the docstring of the `Timedelta.total_seconds()` TST: updated respective testing
db1bf84
to
cafd7dd
Compare
>>> td.total_seconds(ns_precision=True) | ||
521403.010010012 | ||
""" | ||
if ns_precision: |
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.
umm what is this?
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 could not find a way to prevent the problems that the higher precision causes in timezone-related-info (see link from @mroeschke) and because of that I am keeping the super
implementation the default. However, having a total_seconds
method unable to output nanosecond precision is not consistent. My solution for this was to override the method with this version that has a documented kwarg
such that anybody can then know about it (possibly after a bad surprise) without having to check source 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.
adding a keyword like this is not going to fly. if you want to try to fix that issue then happy to incorporate here (or in a pre-cursor). that looks like the test case needs to be updated.
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.
Agreed. The signatures need to be kept compatible with the datetime.timedelta
methods as Timedelta
is a subclass
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. Will retry at a later time.
@mroeschke Now back to the original method signature:
This is puzzling. I can't still figure out the source of the prob. I modified the
|
Looking into https://github.com/pandas-dev/pandas/pull/31155/files#r370721655 might solve this issue |
This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this. |
Thanks for the pull request but appears to have gone stale. If you're interested in continuing please merge in main, address the comments and we can reopen. |
As of now, I could not figure out what's leading to test failing in pandas\tests\scalar\timestamp\test_constructors.py:609.