Skip to content

Commit 97ee2aa

Browse files
committed
TST: Test Series' settitem with Interval and NaN
Fixes #27937. As described in that issue, assigning a mixture of NaN and Interval values into a slice of a categorical-typed series would raise an exception. This is no longer the case.
1 parent 62d1f5c commit 97ee2aa

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pandas/tests/indexing/test_iloc.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,14 @@ def test_iloc_setitem_td64_values_cast_na(self, value):
931931
expected = Series([NaT, 1, 2], dtype="timedelta64[ns]")
932932
tm.assert_series_equal(series, expected)
933933

934+
def test_setitem_mix_of_nan_and_interval(self):
935+
# GH#27937
936+
dtype = CategoricalDtype(categories=[Interval(0, 1)])
937+
ser = Series([np.nan, np.nan, np.nan, np.nan], dtype=dtype)
938+
ser.iloc[:3] = [np.nan, Interval(0, 1), np.nan]
939+
exp = Series([np.nan, Interval(0, 1), np.nan, np.nan], dtype=dtype)
940+
tm.assert_series_equal(ser, exp)
941+
934942
def test_iloc_setitem_empty_frame_raises_with_3d_ndarray(self):
935943
idx = Index([])
936944
obj = DataFrame(np.random.randn(len(idx), len(idx)), index=idx, columns=idx)

0 commit comments

Comments
 (0)