Series.reorder_levels(order: Sequence[Level]) Series[source]#

Rearrange index levels using input order.

May not drop or duplicate levels.


order (list of int representing new level order) – Reference level by number or key.

Return type

type of caller (new object)


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


This method has not been implemented yet. Xorbits will try to execute it with pandas.

This docstring was copied from pandas.core.series.Series.