Skip to content

Commit a34b019

Browse files
authored
TST: Add regression test for DataFrame.where with nullable dtype (pandas-dev#49052) (pandas-dev#63222)
1 parent 190aed6 commit a34b019

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pandas/tests/frame/indexing/test_where.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,3 +1063,13 @@ def test_where_inplace_no_other():
10631063
assert result is df
10641064
expected = DataFrame({"a": [1, np.nan], "b": [np.nan, "y"]})
10651065
tm.assert_frame_equal(df, expected)
1066+
1067+
1068+
def test_where_other_nullable_dtype():
1069+
# GH#49052 DataFrame.where should return nullable dtype when
1070+
# other is a Series with nullable dtype, matching Series.where behavior
1071+
df = DataFrame([1, 2, 3], dtype="int64")
1072+
other = Series([pd.NA, pd.NA, pd.NA], dtype="Int64")
1073+
result = df.where(df > 1, other, axis=0)
1074+
expected = DataFrame({0: Series([pd.NA, 2, 3], dtype="Int64")})
1075+
tm.assert_frame_equal(result, expected)

0 commit comments

Comments
 (0)