Skip to content

Commit 6ca9f23

Browse files
rendnerphofl
authored andcommitted
TST: add test for Index.where (pandas-dev#32413) (pandas-dev#45870)
1 parent 4d4bee2 commit 6ca9f23

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pandas/tests/indexes/numeric/test_indexing.py

+11
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)