pandas.DataFrame.reorder_levels
pandas 3.1.1 · DataFrame · method
Rearrange levels of a hierarchical index.
Call syntax
DataFrame.reorder_levels(order, axis=0)Run the example
Edit the example and select Run Python to see the result.
Parameters
| Parameter | Requirement | Accepted values and behavior |
|---|---|---|
order |
Required Positional or keyword |
list of int or list of str Specify the order in which levels or values should appear. |
axis |
Optional Positional or keyword Default 0 |
{0 or 'index', 1 or 'columns'} Choose which axis the operation acts on. The accepted axis labels depend on the receiver. |
Returns
DataFrame