Skip to content

TST: changed behavior of df.loc on multiindex #43970

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

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions pandas/tests/indexing/multiindex/test_loc.py
Original file line number Diff line number Diff line change
Expand Up @@ -912,3 +912,13 @@ def test_loc_keyerror_rightmost_key_missing():
df = df.set_index(["A", "B"])
with pytest.raises(KeyError, match="^1$"):
df.loc[(100, 1)]
def test_loc_multiindex():
#43599
df = DataFrame(
index = MultiIndex.from_product([list("abc"), list("de"), list("f")]), columns = ["Val"]
)
result = df.loc[np.s_[:,"d",:]]
expected = DataFrame(
index = MultiIndex.from_product([list("abc"), list("d"), list("f")]), columns = ["Val"]
)
tm.assert_frame_equal(result, expected)
1 change: 1 addition & 0 deletions pandas/tests/indexing/test_loc.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from pandas.tests.indexing.common import Base



class TestLoc(Base):
def test_loc_getitem_int(self):

Expand Down