Skip to main content
`Ctrl`+`K`

# pandas.Series.reorder_levels

Series.reorder_levels(order)

  Rearrange index levels using input order.

  May not drop or duplicate levels.

  Parameters:
    order list of int representing new level order

      Reference level by number or key.

  Returns:
    Series

      Type of caller with index as MultiIndex (new object).

  See also

  `DataFrame.reorder_levels`

    Rearrange index or column levels using input `order`.

  Examples

      >>> arrays = [
      ...     np.array(["dog", "dog", "cat", "cat", "bird", "bird"]),
      ...     np.array(["white", "black", "white", "black", "white", "black"]),
      ... ]
      >>> s = pd.Series([1, 2, 3, 3, 5, 2], index=arrays)
      >>> s
      dog   white    1
            black    2
      cat   white    3
            black    3
      bird  white    5
            black    2
      dtype: int64
      >>> s.reorder_levels([1, 0])
      white  dog     1
      black  dog     2
      white  cat     3
      black  cat     3
      white  bird    5
      black  bird    2
      dtype: int64