Skip to content

Commit 1e59742

Browse files
committed
add test for categorical series
1 parent 29ce489 commit 1e59742

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

pandas/tests/frame/methods/test_fillna.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,21 @@ def test_fillna_categorical_nan(self):
256256
idx = TimedeltaIndex(["1 days", "2 days", "1 days", NaT, NaT])
257257
df = DataFrame({"a": Categorical(idx)})
258258
tm.assert_frame_equal(df.fillna(value=NaT), df)
259+
260+
def test_fillna_with_categorical_series(self):
261+
df = DataFrame({
262+
'cats': Categorical(['A', 'B', 'C']),
263+
'ints': [1.0, 2.0, np.nan]
264+
})
265+
266+
filler = Series(Categorical([10.0, 20.0, 30.0]))
267+
df.fillna({'ints': filler}, inplace=True)
268+
269+
expected = DataFrame({
270+
'cats': Categorical(['A', 'B', 'C']),
271+
'ints': [1.0, 2.0, 30.0]
272+
})
273+
tm.assert_frame_equal(df, expected)
259274

260275
def test_fillna_no_downcast(self, frame_or_series):
261276
# GH#45603 preserve object dtype

0 commit comments

Comments
 (0)