Skip to content

Commit d33f550

Browse files
committed
adding unit test for GH22332
1 parent c3358f2 commit d33f550

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

pandas/tests/indexes/test_base.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,6 +1245,19 @@ def test_get_indexer(self):
12451245
e1 = np.array([1, 3, -1], dtype=np.intp)
12461246
assert_almost_equal(r1, e1)
12471247

1248+
def test_get_indexer_with_NA_values(self):
1249+
# GH 22332
1250+
# check pairwise, that no pair of na values
1251+
# is mangled
1252+
na_values = [None, np.nan, pd.NaT]
1253+
for f in na_values:
1254+
for s in na_values:
1255+
if f is not s: # otherwise not unique
1256+
arr = np.array([f, s], dtype=np.object)
1257+
result = pd.Index(arr, dtype=np.object).get_indexer([f, s, 'Unknown'])
1258+
expected = np.array([0, 1, -1], dtype=np.int64)
1259+
tm.assert_numpy_array_equal(result, expected)
1260+
12481261
@pytest.mark.parametrize("reverse", [True, False])
12491262
@pytest.mark.parametrize("expected,method", [
12501263
(np.array([-1, 0, 0, 1, 1], dtype=np.intp), 'pad'),

0 commit comments

Comments
 (0)