Skip to content

Commit 980f567

Browse files
committed
TST: examples from OP
1 parent 9c202a1 commit 980f567

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pandas/tests/series/test_constructors.py

+7
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,13 @@ def test_constructor_coerce_float_valid(self, float_dtype):
688688
expected = Series([1, 2, 3.5]).astype(float_dtype)
689689
tm.assert_series_equal(s, expected)
690690

691+
def test_constructor_invalid_coerce_ints_with_float_nan(self, any_int_dtype):
692+
# GH 22585
693+
694+
msg = "cannot convert float NaN to integer"
695+
with pytest.raises(ValueError, match=msg):
696+
pd.Series([1, 2, np.nan], dtype=any_int_dtype)
697+
691698
def test_constructor_dtype_no_cast(self):
692699
# see gh-1572
693700
s = Series([1, 2, 3])

0 commit comments

Comments
 (0)