Skip to content

Commit f4a696d

Browse files
committed
TST: test get_loc on MultiIndex with tuple containing bool
1 parent 79b4a0c commit f4a696d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pandas/tests/indexes/test_multi.py

+11
Original file line numberDiff line numberDiff line change
@@ -1298,6 +1298,17 @@ def test_get_loc_implicit_cast(self, level, dtypes):
12981298
idx = MultiIndex.from_product(levels)
12991299
assert idx.get_loc(tuple(key)) == 3
13001300

1301+
def test_get_loc_cast_bool(self):
1302+
# GH 19086 : int is casted to bool, but not vice-versa
1303+
levels = [[False, True], np.arange(2, dtype='int64')]
1304+
idx = MultiIndex.from_product(levels)
1305+
1306+
assert idx.get_loc((0, 1)) == 1
1307+
assert idx.get_loc((1, 0)) == 2
1308+
1309+
pytest.raises(KeyError, idx.get_loc, (False, True))
1310+
pytest.raises(KeyError, idx.get_loc, (True, False))
1311+
13011312
def test_slice_locs(self):
13021313
df = tm.makeTimeDataFrame()
13031314
stacked = df.stack()

0 commit comments

Comments
 (0)