Skip to content

Commit 494025c

Browse files
authored
TST: added test for pd.where overflow error GH31687 (#49926)
* TST: added test for pd.where overflow error GH31687 * updated to better match original issue * typo'd datetime.date * removed date object from test
1 parent b973162 commit 494025c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pandas/tests/frame/indexing/test_where.py

+12
Original file line numberDiff line numberDiff line change
@@ -1017,3 +1017,15 @@ def test_where_producing_ea_cond_for_np_dtype():
10171017
{"a": Series([pd.NA, pd.NA, 2], dtype="Int64"), "b": [np.nan, 2, 3]}
10181018
)
10191019
tm.assert_frame_equal(result, expected)
1020+
1021+
1022+
@pytest.mark.parametrize(
1023+
"replacement", [0.001, True, "snake", None, datetime(2022, 5, 4)]
1024+
)
1025+
def test_where_int_overflow(replacement):
1026+
# GH 31687
1027+
df = DataFrame([[1.0, 2e25, "nine"], [np.nan, 0.1, None]])
1028+
result = df.where(pd.notnull(df), replacement)
1029+
expected = DataFrame([[1.0, 2e25, "nine"], [replacement, 0.1, replacement]])
1030+
1031+
tm.assert_frame_equal(result, expected)

0 commit comments

Comments
 (0)