|
20 | 20 | from pandas.errors import InvalidIndexError
|
21 | 21 |
|
22 | 22 | from pandas import (
|
| 23 | + NA, |
23 | 24 | DatetimeIndex,
|
24 | 25 | Index,
|
25 | 26 | IntervalIndex,
|
@@ -221,6 +222,13 @@ def test_get_loc_generator(self, index):
|
221 | 222 | # MultiIndex specifically checks for generator; others for scalar
|
222 | 223 | index.get_loc(x for x in range(5))
|
223 | 224 |
|
| 225 | + def test_get_loc_masked_duplicated_na(self): |
| 226 | + # GH#48411 |
| 227 | + idx = Index([1, 2, NA, NA], dtype="Int64") |
| 228 | + result = idx.get_loc(NA) |
| 229 | + expected = np.array([False, False, True, True]) |
| 230 | + tm.assert_numpy_array_equal(result, expected) |
| 231 | + |
224 | 232 |
|
225 | 233 | class TestGetIndexer:
|
226 | 234 | def test_get_indexer_base(self, index):
|
@@ -253,6 +261,13 @@ def test_get_indexer_consistency(self, index):
|
253 | 261 | assert isinstance(indexer, np.ndarray)
|
254 | 262 | assert indexer.dtype == np.intp
|
255 | 263 |
|
| 264 | + def test_get_indexer_masked_duplicated_na(self): |
| 265 | + # GH#48411 |
| 266 | + idx = Index([1, 2, NA, NA], dtype="Int64") |
| 267 | + result = idx.get_indexer_for(Index([1, NA], dtype="Int64")) |
| 268 | + expected = np.array([0, 2, 3], dtype=result.dtype) |
| 269 | + tm.assert_numpy_array_equal(result, expected) |
| 270 | + |
256 | 271 |
|
257 | 272 | class TestConvertSliceIndexer:
|
258 | 273 | def test_convert_almost_null_slice(self, index):
|
|
0 commit comments