Skip to main content
`Ctrl`+`K`

# pandas.Series.cat.ordered

Series.cat.ordered

  Whether the categories have an ordered relationship.

  This property returns True if the categories are ordered, meaning they have a meaningful order that allows comparison operations.

  See also

  `set_ordered`

    Set the ordered attribute.

  `as_ordered`

    Set the Categorical to be ordered.

  `as_unordered`

    Set the Categorical to be unordered.

  Examples

  For `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

  For `pandas.Categorical`:

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

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

  For `pandas.CategoricalIndex`:

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

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