-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
CLN: clarify TypeError for IndexSlice argument to pd.xs #35411
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
8f947ad
to
71a63bd
Compare
pandas/core/generic.py
Outdated
try: | ||
loc, new_index = self.index.get_loc_level(key, drop_level=drop_level) | ||
except TypeError: | ||
raise TypeError(f"Expected label or tuple of labels, got {key}") |
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 from e
(need to add the the except as well)
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.
if you can move the test; merge master and ping on green.
pandas/tests/test_multilevel.py
Outdated
@@ -1280,6 +1280,26 @@ def test_level_with_tuples(self): | |||
tm.assert_frame_equal(result, expected) | |||
tm.assert_frame_equal(result2, expected) | |||
|
|||
def test_xs_with_IndexSlice(self): | |||
# GH 35301 |
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 move to: pandas/tests/indexing/multiindex/test_xs.py
90d0f8b
to
a2e51bc
Compare
a2e51bc
to
9ed2654
Compare
thanks @arw2019 very nice (failure is unrelated) |
great! thanks @jreback for reviewing |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff
As per discussion in #35301 we do not support
IndexSlice
arguments toxs
. This PR aims to clarify theTypeError
thrown when that happens.I created a separate issue to house the discussion re: functionality of
loc
vsxs
(#35418).