pyspark.pandas.CategoricalIndex.as_ordered ¶
-
CategoricalIndex.
as_ordered
( inplace : bool = False ) → Optional [ pyspark.pandas.indexes.category.CategoricalIndex ] [source] ¶ -
设置分类变量为有序。
- Parameters
-
- inplace bool, default False
-
是否就地设置有序属性,或者返回此分类的有序属性设置为True的副本。
- Returns
-
- CategoricalIndex or None
-
有序分类或如果
inplace=True
则为无。
示例
>>> idx = ps.CategoricalIndex(list("abbccc")) >>> idx CategoricalIndex(['a', 'b', 'b', 'c', 'c', 'c'], categories=['a', 'b', 'c'], ordered=False, dtype='category')
>>> idx.as_ordered() CategoricalIndex(['a', 'b', 'b', 'c', 'c', 'c'], categories=['a', 'b', 'c'], ordered=True, dtype='category')