Skip to content

Commit e06bd63

Browse files
committed
TST: test get_loc on MultiIndex with levels of different dtypes
1 parent 60bf12c commit e06bd63

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pandas/tests/indexes/test_multi.py

+9
Original file line numberDiff line numberDiff line change
@@ -1262,6 +1262,15 @@ def test_get_loc_missing_nan(self):
12621262
pytest.raises(KeyError, idx.get_loc, np.nan)
12631263
pytest.raises(KeyError, idx.get_loc, [np.nan])
12641264

1265+
@pytest.mark.parametrize('dtype1', [int, float, bool, str])
1266+
@pytest.mark.parametrize('dtype2', [int, float, bool, str])
1267+
def test_get_loc_multiple_dtypes(self, dtype1, dtype2):
1268+
# GH 18520
1269+
levels = [np.array([0, 1]).astype(dtype1),
1270+
np.array([0, 1]).astype(dtype2)]
1271+
idx = pd.MultiIndex.from_product(levels)
1272+
assert idx.get_loc(idx[2]) == 2
1273+
12651274
@pytest.mark.parametrize('level', [0, 1])
12661275
@pytest.mark.parametrize('dtypes', [[int, float], [float, int]])
12671276
def test_get_loc_implicit_cast(self, level, dtypes):

0 commit comments

Comments
 (0)