We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 24c2139 commit de98025Copy full SHA for de98025
pandas/tests/series/methods/test_fillna.py
@@ -851,6 +851,24 @@ def test_fillna_pos_args_deprecation(self):
851
expected = Series([1, 2, 3, 0], dtype=float)
852
tm.assert_series_equal(result, expected)
853
854
+ @pytest.mark.parametrize(
855
+ "input, input_fillna, expected_data, expected_categories",
856
+ [
857
+ (["A", "B", None, "A"], "B", ["A", "B", "B", "A"], ["A", "B"]),
858
+ (["A", "B", np.nan, "A"], "B", ["A", "B", "B", "A"], ["A", "B"]),
859
+ ],
860
+ )
861
+ def test_fillna_categorical_accept_same_type(
862
+ self, input, input_fillna, expected_data, expected_categories
863
+ ):
864
+ # GH32414
865
+ cat = Categorical(input)
866
+ ser = Series(cat).fillna(input_fillna)
867
+ filled = cat.fillna(ser)
868
+ result = cat.fillna(filled)
869
+ expected = Categorical(expected_data, categories=expected_categories)
870
+ tm.assert_categorical_equal(result, expected)
871
+
872
873
class TestFillnaPad:
874
def test_fillna_bug(self):
0 commit comments