Skip to content

Commit 75eb0cf

Browse files
authored
TST: Add test for missing fillvalue in categorical dtype (#37720)
1 parent 8dd2d95 commit 75eb0cf

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

pandas/tests/indexes/categorical/test_reindex.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import numpy as np
2+
import pytest
23

3-
from pandas import Categorical, CategoricalIndex, Index
4+
from pandas import Categorical, CategoricalIndex, Index, Series
45
import pandas._testing as tm
56

67

@@ -51,3 +52,10 @@ def test_reindex_empty_index(self):
5152
res, indexer = c.reindex(["a", "b"])
5253
tm.assert_index_equal(res, Index(["a", "b"]), exact=True)
5354
tm.assert_numpy_array_equal(indexer, np.array([-1, -1], dtype=np.intp))
55+
56+
def test_reindex_missing_category(self):
57+
# GH: 18185
58+
ser = Series([1, 2, 3, 1], dtype="category")
59+
msg = "'fill_value=-1' is not present in this Categorical's categories"
60+
with pytest.raises(ValueError, match=msg):
61+
ser.reindex([1, 2, 3, 4, 5], fill_value=-1)

0 commit comments

Comments
 (0)