Skip to content

Commit 2aa6e79

Browse files
gfyoungjreback
authored andcommitted
TST: Test CategoricalIndex in test_is_categorical (#16243)
Follow-up to gh-16237.
1 parent 5dd3b43 commit 2aa6e79

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

pandas/core/dtypes/common.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -205,13 +205,15 @@ def is_categorical(arr):
205205
>>> is_categorical([1, 2, 3])
206206
False
207207
208-
Categoricals and Series Categoricals will return True.
208+
Categoricals, Series Categoricals, and CategoricalIndex will return True.
209209
210210
>>> cat = pd.Categorical([1, 2, 3])
211211
>>> is_categorical(cat)
212212
True
213213
>>> is_categorical(pd.Series(cat))
214214
True
215+
>>> is_categorical(pd.CategoricalIndex([1, 2, 3]))
216+
True
215217
"""
216218

217219
return isinstance(arr, ABCCategorical) or is_categorical_dtype(arr)

pandas/tests/dtypes/test_common.py

+1
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ def test_is_categorical():
158158
cat = pd.Categorical([1, 2, 3])
159159
assert com.is_categorical(cat)
160160
assert com.is_categorical(pd.Series(cat))
161+
assert com.is_categorical(pd.CategoricalIndex([1, 2, 3]))
161162

162163
assert not com.is_categorical([1, 2, 3])
163164

0 commit comments

Comments
 (0)