- API reference
- pandas.CategoricalIndex
- pandas.Categ...
pandas.CategoricalIndex.as_ordered#
- CategoricalIndex.as_ordered(*args,**kwargs)[source]#
Set the Categorical to be ordered.
- Returns:
- Categorical
Ordered Categorical.
Examples
For
pandas.Series
:>>>ser=pd.Series(['a','b','c','a'],dtype='category')>>>ser.cat.orderedFalse>>>ser=ser.cat.as_ordered()>>>ser.cat.orderedTrue
>>>ci=pd.CategoricalIndex(['a','b','c','a'])>>>ci.orderedFalse>>>ci=ci.as_ordered()>>>ci.orderedTrue
On this page