File tree Expand file tree Collapse file tree 2 files changed +4
-1
lines changed Expand file tree Collapse file tree 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):
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 )
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments