Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions pandas/tests/frame/indexing/test_where.py
Original file line number Diff line number Diff line change
Expand Up @@ -771,3 +771,13 @@ def test_where_non_keyword_deprecation():
result = s.where(s > 1, 10, False)
expected = DataFrame([10, 10, 2, 3, 4])
tm.assert_frame_equal(expected, result)


def test_where_columns_casting():
# GH 42295

d1 = DataFrame({"a": [1.0, 2.0], 'b': [3, np.nan]})
result = d1.where(pd.notnull(d1), None).dtypes
# make sure dtypes don't change
expected = d1.dtypes
tm.assert_series_equal(expected, result)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of comparing the .dtype results. Could you compare the DataFrame result of result of d1.where(pd.notnull(d1), None)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, thanks for the review. I updated it.