Skip to content

Commit af2dfbf

Browse files
committed
TST: added test for pd.where overflow error GH31687
1 parent 9fe5ea4 commit af2dfbf

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

pandas/tests/frame/indexing/test_where.py

+16-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@
1818
isna,
1919
)
2020
import pandas._testing as tm
21-
from pandas._testing._hypothesis import OPTIONAL_ONE_OF_ALL
21+
from pandas._testing._hypothesis import (
22+
DATETIME_JAN_1_1900_OPTIONAL_TZ,
23+
OPTIONAL_ONE_OF_ALL,
24+
)
2225

2326

2427
@pytest.fixture(params=["default", "float_string", "mixed_float", "mixed_int"])
@@ -1017,3 +1020,15 @@ def test_where_producing_ea_cond_for_np_dtype():
10171020
{"a": Series([pd.NA, pd.NA, 2], dtype="Int64"), "b": [np.nan, 2, 3]}
10181021
)
10191022
tm.assert_frame_equal(result, expected)
1023+
1024+
1025+
@pytest.mark.parametrize(
1026+
"replacement", [0.001, True, "snake", DATETIME_JAN_1_1900_OPTIONAL_TZ]
1027+
)
1028+
def test_where_int_overflow(replacement):
1029+
# GH 31687
1030+
df = DataFrame([[1.0, 2e19, "nine"], [np.nan, 0.1, None]])
1031+
result = df.where(pd.notnull(df), replacement)
1032+
expected = DataFrame([[1.0, 2e19, "nine"], [replacement, 0.1, replacement]])
1033+
1034+
tm.assert_frame_equal(result, expected)

0 commit comments

Comments
 (0)