pandas.Categorical.ordered #

属性 分类。订购[来源] #

类别是否具有有序关系。

例子

为了pandas.Series

>>> ser = pd.Series(['a', 'b', 'c', 'a'], dtype='category')
>>> ser.cat.ordered
False
>>> raw_cat = pd.Categorical(['a', 'b', 'c', 'a'], ordered=True)
>>> ser = pd.Series(raw_cat)
>>> ser.cat.ordered
True

为了pandas.Categorical

>>> cat = pd.Categorical(['a', 'b'], ordered=True)
>>> cat.ordered
True
>>> cat = pd.Categorical(['a', 'b'], ordered=False)
>>> cat.ordered
False

为了pandas.CategoricalIndex

>>> ci = pd.CategoricalIndex(['a', 'b'], ordered=True)
>>> ci.ordered
True
>>> ci = pd.CategoricalIndex(['a', 'b'], ordered=False)
>>> ci.ordered
False