-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: raise KeyError if MultiIndex.get_loc_level is asked unused label #22230
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: raise KeyError if MultiIndex.get_loc_level is asked unused label #22230
Conversation
Codecov Report
@@ Coverage Diff @@
## master #22230 +/- ##
==========================================
+ Coverage 92.07% 92.07% +<.01%
==========================================
Files 169 169
Lines 50683 50684 +1
==========================================
+ Hits 46666 46668 +2
+ Misses 4017 4016 -1
Continue to review full report at Codecov.
|
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 comments
@@ -271,6 +271,10 @@ def test_get_loc_level(): | |||
assert new_index is None | |||
|
|||
pytest.raises(KeyError, index.get_loc_level, (2, 2)) | |||
# GH 22221: unused label |
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.
can you add the issue number here
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.
Do you mean repeat it below?
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.
this is good as written
pandas/core/indexes/multi.py
Outdated
|
||
if level > 0 or self.lexsort_depth == 0: | ||
# Desired level is not sorted | ||
locs = np.array(labels == code, dtype=bool) |
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 you can pass copy=False
here
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.
can you do this
can you also add the original OP test somewhere. |
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.
minor comment
pandas/core/indexes/multi.py
Outdated
|
||
if level > 0 or self.lexsort_depth == 0: | ||
# Desired level is not sorted | ||
locs = np.array(labels == code, dtype=bool) |
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.
can you do this
@@ -271,6 +271,10 @@ def test_get_loc_level(): | |||
assert new_index is None | |||
|
|||
pytest.raises(KeyError, index.get_loc_level, (2, 2)) | |||
# GH 22221: unused label |
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.
this is good as written
ea539d8
to
31b55c4
Compare
thanks @toobaz |
…pandas-dev#22230) * BUG: raise KeyError if MultiIndex.get_loc_level is asked unused label closes pandas-dev#22221 * TST: test groupby.apply() with user-defined function returning an empty chunk * CLN: remove named lambda
git diff upstream/master -u -- "*.py" | flake8 --diff