Skip to main content
`Ctrl`+`K`

# pandas.Series.cat.as_ordered

Series.cat.as_ordered()

  Set the Categorical to be ordered.

  Returns:
    Categorical

      Ordered Categorical.

  See also

  `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
      >>> ser = ser.cat.as_ordered()
      >>> ser.cat.ordered
      True

  For `pandas.CategoricalIndex`:

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