Skip to content
Closed
Changes from 1 commit
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
Next Next commit
add test for categorical series
  • Loading branch information
thaiv28 committed Sep 10, 2025
commit 1e59742eb0b86aefc37a6d55cc03e16fc8cf771c
15 changes: 15 additions & 0 deletions pandas/tests/frame/methods/test_fillna.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,21 @@ def test_fillna_categorical_nan(self):
idx = TimedeltaIndex(["1 days", "2 days", "1 days", NaT, NaT])
df = DataFrame({"a": Categorical(idx)})
tm.assert_frame_equal(df.fillna(value=NaT), df)

def test_fillna_with_categorical_series(self):
df = DataFrame({
'cats': Categorical(['A', 'B', 'C']),
'ints': [1.0, 2.0, np.nan]
})

filler = Series(Categorical([10.0, 20.0, 30.0]))
df.fillna({'ints': filler}, inplace=True)

expected = DataFrame({
'cats': Categorical(['A', 'B', 'C']),
'ints': [1.0, 2.0, 30.0]
})
tm.assert_frame_equal(df, expected)

def test_fillna_no_downcast(self, frame_or_series):
# GH#45603 preserve object dtype
Expand Down
Loading