Skip to content

Commit c0650be

Browse files
committed
TST: test get_loc on MultiIndex with levels of different dtypes
1 parent 8e1bdcd commit c0650be

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
@@ -1277,6 +1277,15 @@ def test_get_loc_missing_nan(self):
12771277
pytest.raises(KeyError, idx.get_loc, np.nan)
12781278
pytest.raises(KeyError, idx.get_loc, [np.nan])
12791279

1280+
@pytest.mark.parametrize('dtype1', [int, float, bool, str])
1281+
@pytest.mark.parametrize('dtype2', [int, float, bool, str])
1282+
def test_get_loc_multiple_dtypes(self, dtype1, dtype2):
1283+
# GH 18520
1284+
levels = [np.array([0, 1]).astype(dtype1),
1285+
np.array([0, 1]).astype(dtype2)]
1286+
idx = pd.MultiIndex.from_product(levels)
1287+
assert idx.get_loc(idx[2]) == 2
1288+
12801289
@pytest.mark.parametrize('level', [0, 1])
12811290
@pytest.mark.parametrize('dtypes', [[int, float], [float, int]])
12821291
def test_get_loc_implicit_cast(self, level, dtypes):

0 commit comments

Comments
 (0)