File tree 2 files changed +4
-1
lines changed
2 files changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -205,13 +205,15 @@ def is_categorical(arr):
205
205
>>> is_categorical([1, 2, 3])
206
206
False
207
207
208
- Categoricals and Series Categoricals will return True.
208
+ Categoricals, Series Categoricals, and CategoricalIndex will return True.
209
209
210
210
>>> cat = pd.Categorical([1, 2, 3])
211
211
>>> is_categorical(cat)
212
212
True
213
213
>>> is_categorical(pd.Series(cat))
214
214
True
215
+ >>> is_categorical(pd.CategoricalIndex([1, 2, 3]))
216
+ True
215
217
"""
216
218
217
219
return isinstance (arr , ABCCategorical ) or is_categorical_dtype (arr )
Original file line number Diff line number Diff line change @@ -158,6 +158,7 @@ def test_is_categorical():
158
158
cat = pd .Categorical ([1 , 2 , 3 ])
159
159
assert com .is_categorical (cat )
160
160
assert com .is_categorical (pd .Series (cat ))
161
+ assert com .is_categorical (pd .CategoricalIndex ([1 , 2 , 3 ]))
161
162
162
163
assert not com .is_categorical ([1 , 2 , 3 ])
163
164
You can’t perform that action at this time.
0 commit comments