Skip to content

TST: Series constructor behavior is consistent for mixed float NaN and int dtype data #37090

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 25, 2020
Merged
Changes from all 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
7 changes: 7 additions & 0 deletions pandas/tests/series/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,13 @@ def test_constructor_coerce_float_valid(self, float_dtype):
expected = Series([1, 2, 3.5]).astype(float_dtype)
tm.assert_series_equal(s, expected)

def test_constructor_invalid_coerce_ints_with_float_nan(self, any_int_dtype):
# GH 22585

msg = "cannot convert float NaN to integer"
with pytest.raises(ValueError, match=msg):
pd.Series([1, 2, np.nan], dtype=any_int_dtype)

def test_constructor_dtype_no_cast(self):
# see gh-1572
s = Series([1, 2, 3])
Expand Down