-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
[BUG] TimedeltaIndex intersects with decreasing TimedeltaIndex #25661
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
Codecov Report
@@ Coverage Diff @@
## master #25661 +/- ##
==========================================
+ Coverage 91.29% 91.29% +<.01%
==========================================
Files 173 173
Lines 52961 52966 +5
==========================================
+ Hits 48350 48357 +7
+ Misses 4611 4609 -2
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #25661 +/- ##
==========================================
- Coverage 91.82% 91.29% -0.53%
==========================================
Files 175 173 -2
Lines 52551 52966 +415
==========================================
+ Hits 48256 48357 +101
- Misses 4295 4609 +314
Continue to review full report at Codecov.
|
doc/source/whatsnew/v0.25.0.rst
Outdated
@@ -141,7 +141,7 @@ Datetimelike | |||
Timedelta | |||
^^^^^^^^^ | |||
|
|||
- | |||
- bug when TimedeltaIndex intersects with another decreasing TimedeltaIndex (:issue:`17391`) |
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.
Capitalize bug. Reference the method :meth:`TimedeltaIndex.intersection`.
Remove the trailing whitespace.
pandas/core/indexes/timedeltas.py
Outdated
@@ -474,6 +474,10 @@ def intersection(self, other): | |||
return self | |||
if len(other) == 0: | |||
return other | |||
|
|||
self = self.sort_values() |
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.
Sorting can be relatively expensive. Are we able to avoid this?
I think this would also break sort=False
.
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 would think that we could extract the i8
values and re-use Int64Index.sort
. Is that an option?
can you merge master |
git diff upstream/master -u -- "*.py" | flake8 --diff
Beside the bug of decreasing TimedeltaIndex, this PR also solve the following
The above is also added into the tests.