Skip to content

Commit 90bfabc

Browse files
author
Marco Gorelli
committed
Remove argument new_categories from test function, add test case where fill value series values are in different order
1 parent 6ed5f08 commit 90bfabc

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

pandas/tests/series/test_missing.py

+6-14
Original file line numberDiff line numberDiff line change
@@ -579,25 +579,17 @@ def test_fillna_categorical(self, fill_value, expected_output):
579579
tm.assert_series_equal(s.fillna(fill_value), exp)
580580

581581
@pytest.mark.parametrize(
582-
"new_categories, fill_value, expected_output",
582+
"fill_value, expected_output",
583583
[
584-
(
585-
["c", "d", "e"],
586-
Series(["a", "b", "c", "d", "e"]),
587-
["a", "b", "b", "d", "e"],
588-
)
584+
(Series(["a", "b", "c", "d", "e"]), ["a", "b", "b", "d", "e"]),
585+
(Series(["b", "d", "a", "d", "a"]), ["a", "d", "b", "d", "a"]),
589586
],
590587
)
591-
def test_fillna_categorical_with_new_categories(
592-
self, new_categories, fill_value, expected_output
593-
):
588+
def test_fillna_categorical_with_new_categories(self, fill_value, expected_output):
594589
# GH 26215
595590
data = ["a", np.nan, "b", np.nan, np.nan]
596-
s = Series(Categorical(data, categories=["a", "b"]))
597-
s.cat.add_categories(new_categories, inplace=True)
598-
exp = Series(
599-
Categorical(expected_output, categories=["a", "b"] + new_categories)
600-
)
591+
s = Series(Categorical(data, categories=["a", "b", "c", "d", "e"]))
592+
exp = Series(Categorical(expected_output, categories=["a", "b", "c", "d", "e"]))
601593
tm.assert_series_equal(s.fillna(fill_value), exp)
602594

603595
def test_fillna_categorical_raise(self):

0 commit comments

Comments
 (0)