Skip to content

Commit 96515f8

Browse files
committed
TST: add test for Index.where (#32413)
1 parent ee0aab2 commit 96515f8

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pandas/tests/indexes/numeric/test_indexing.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,17 @@ def test_where_uint64(self):
424424
result = idx.putmask(~mask, other)
425425
tm.assert_index_equal(result, expected)
426426

427+
def test_where_infers_type_instead_of_trying_to_convert_string_to_float(self):
428+
# GH 32413
429+
index = Index([1, np.nan])
430+
cond = index.notna()
431+
other = Index(["a", "b"], dtype="string")
432+
433+
expected = Index([1.0, "b"])
434+
result = index.where(cond, other)
435+
436+
tm.assert_index_equal(result, expected)
437+
427438

428439
class TestTake:
429440
@pytest.mark.parametrize("klass", [Float64Index, Int64Index, UInt64Index])

0 commit comments

Comments
 (0)