Skip to content

Commit 96a97be

Browse files
committed
TST: test get_loc on MultiIndex with tuple containing bool
1 parent a1966e1 commit 96a97be

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
@@ -1283,6 +1283,17 @@ def test_get_loc_implicit_cast(self, level, dtypes):
12831283
idx = MultiIndex.from_product(levels)
12841284
assert idx.get_loc(tuple(key)) == 3
12851285

1286+
def test_get_loc_cast_bool(self):
1287+
# GH 19086 : int is casted to bool, but not vice-versa
1288+
levels = [[False, True], np.arange(2, dtype='int64')]
1289+
idx = MultiIndex.from_product(levels)
1290+
1291+
assert idx.get_loc((0, 1)) == 1
1292+
assert idx.get_loc((1, 0)) == 2
1293+
1294+
pytest.raises(KeyError, idx.get_loc, (False, True))
1295+
pytest.raises(KeyError, idx.get_loc, (True, False))
1296+
12861297
def test_slice_locs(self):
12871298
df = tm.makeTimeDataFrame()
12881299
stacked = df.stack()

0 commit comments

Comments
 (0)