-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Fix is_unique
regression for slices of Index
es
#57958
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
Co-authored-by: Abdulaziz Aloqeely <[email protected]>
A note or question for reviewers: With this extra code, is pre-computing uniqueness and monotonicity for indexes still a performance boost? I'm still seeing gains for calling This PR:
Without pre-computing:
|
But it only slows it down by a large margin if |
The pre-computing code should run anytime EDIT: as a quick check, I raised in |
I think To avoid scope creep in this issue, how about I open a separate issue for a performance check and have this PR move forward with the bug fix? |
pandas/tests/indexes/test_base.py
Outdated
assert filtered_index.is_unique | ||
|
||
def test_slice_is_montonic(self): | ||
"""Test that is_monotonic resets on slices.""" |
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.
Not exactly "resets on slices" after your last commit
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.
Is a docstring and a comment referencing the GitHub issue too much?
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 think the function name explains it all, but it's up to you
Sure, sounds good to me. |
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. |
Sorry this is not stale, @WillAyd mind having a look? Initially looks good to me. |
Updated for 3.0.0 now. |
Is there anything else I should do to make this PR not stale any more? |
I removed the label. @mroeschke mind taking a look please? |
Co-authored-by: Abdulaziz Aloqeely <[email protected]>
index = Index([1, 2, 3, 3]) | ||
assert not index.is_monotonic_decreasing | ||
|
||
filtered_index = index[2:].copy() |
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.
Could you also test a null slice i.e. index[:]
Co-authored-by: Matthew Roeschke <[email protected]>
Thanks @rob-sil |
doc/source/whatsnew/v3.0.0.rst
file if fixing a bug or adding a new feature.Slicing a unique
Index
will always give another uniqueIndex
, so inheriting uniqueness flags is safe and efficient. However, the slice of a non-uniqueIndex
can end up with unique elements. Inheriting in the non-unique case caused the regression so this PR changes the code to just inherit when the baseIndex
is marked as unique.