Skip to content

Commit

Permalink
Update test_fillna.py (pandas-dev#46161)
Browse files Browse the repository at this point in the history
* Update test_fillna.py

* change test function name

* change assert categorical equal
  • Loading branch information
Khor Chean Wei authored Feb 27, 2022
1 parent 24c2139 commit de98025
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions pandas/tests/series/methods/test_fillna.py
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,24 @@ def test_fillna_pos_args_deprecation(self):
expected = Series([1, 2, 3, 0], dtype=float)
tm.assert_series_equal(result, expected)

@pytest.mark.parametrize(
"input, input_fillna, expected_data, expected_categories",
[
(["A", "B", None, "A"], "B", ["A", "B", "B", "A"], ["A", "B"]),
(["A", "B", np.nan, "A"], "B", ["A", "B", "B", "A"], ["A", "B"]),
],
)
def test_fillna_categorical_accept_same_type(
self, input, input_fillna, expected_data, expected_categories
):
# GH32414
cat = Categorical(input)
ser = Series(cat).fillna(input_fillna)
filled = cat.fillna(ser)
result = cat.fillna(filled)
expected = Categorical(expected_data, categories=expected_categories)
tm.assert_categorical_equal(result, expected)


class TestFillnaPad:
def test_fillna_bug(self):
Expand Down

0 comments on commit de98025

Please sign in to comment.