-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: MultiIndex slicing with negative step #46156
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: MultiIndex slicing with negative step #46156
Conversation
awesome. cc @phofl @jbrockmendel if any comments |
gentle ping, but no worries if you want to give it more time for review. have a follow-on after this one. |
@lukemanley yeah just having @jbrockmendel and @phofl give it a quick look over |
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.
Small comment, otherwise lgtm
doc/source/whatsnew/v1.5.0.rst
Outdated
@@ -393,6 +393,9 @@ Missing | |||
|
|||
MultiIndex | |||
^^^^^^^^^^ | |||
- Bug in :meth:`DataFrame.loc` returning empty result when indexer contains a slice with a negative step size and non-null start/stop values (:issue:`46156`) | |||
- Bug in :meth:`DataFrame.loc` raising when indexer contains a slice with a negative step size other than -1 (:issue:`46156`) | |||
- Bug in :meth:`DataFrame.loc` raising when indexer contains a slice with a negative step size and slicing a non-int labeled index level (:issue:`46156`) |
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 clarify that the df has a MultiIndex?
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.
updated, thanks
…ukemanley/pandas into multiindex-slice-negative-step
thanks @lukemanley your other PR likely needs to be rebased |
doc/source/whatsnew/v1.5.0.rst
file if fixing a bug or adding a new feature.MultiIndex label-based (.loc) slicing with a negative step size appears to contain a few bugs.
#38071 may have partially addressed negative step size issues, but a few issues seem to remain.
I believe this PR fixes the following:
Bug 1: slicing with non-null start/stop values returns an empty frame
Bug 2: negative step size other than -1 raises
Bug 3: slicing a non-int labeled index level raises
The tests have been expanded to cover these cases.