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:
    orderlist of int representing new level order

      Reference level by number or key.

  Returns:
    type of caller (new object)

  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