Skip to content

Commit c17656c

Browse files
maximilianaccardoMaximilian CarrMaximilian Carr
authored
TST: Add testing to df.where() typecasting as per GH 42295 (#43173)
* Add testing to df.where() typecasting as per GH 42295 * Fix style * Directly compare data frames * Fix pre-commit * Rename dataframe to df * create expected before calling where Co-authored-by: Maximilian Carr <[email protected]> Co-authored-by: Maximilian Carr <[email protected]>
1 parent 470a062 commit c17656c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pandas/tests/frame/indexing/test_where.py

+10
Original file line numberDiff line numberDiff line change
@@ -771,3 +771,13 @@ def test_where_non_keyword_deprecation():
771771
result = s.where(s > 1, 10, False)
772772
expected = DataFrame([10, 10, 2, 3, 4])
773773
tm.assert_frame_equal(expected, result)
774+
775+
776+
def test_where_columns_casting():
777+
# GH 42295
778+
779+
df = DataFrame({"a": [1.0, 2.0], "b": [3, np.nan]})
780+
expected = df.copy()
781+
result = df.where(pd.notnull(df), None)
782+
# make sure dtypes don't change
783+
tm.assert_frame_equal(expected, result)

0 commit comments

Comments
 (0)