pandas.Series.sort_index
pandas 3.1.1 · Series and accessors · method
Order rows or columns by their labels.
Call syntax
Series.sort_index(…) Full signature
Series.sort_index(
*,
axis=0,
level=None,
ascending=True,
inplace=…,
kind='quicksort',
na_position='last',
sort_remaining=True,
ignore_index=False,
key=None,
)Run the example
Edit the example and select Run Python to see the result.
Parameters
| Parameter | Requirement | Accepted values and behavior |
|---|---|---|
axis |
Optional Keyword only Default 0 |
{0 or 'index'} Choose which axis the operation acts on. The accepted axis labels depend on the receiver. |
level |
Optional Keyword only Default None |
int Choose an index level by name or integer position. |
ascending |
Optional Keyword only Default True |
bool or list-like of bools Choose ascending or descending order. Some sorting methods take one flag per sort key. |
inplace |
Optional Keyword only |
bool Choose whether to change the existing object. Where supported, an in-place call typically returns None. |
kind |
Optional Keyword only Default 'quicksort' |
{'quicksort', 'mergesort', 'heapsort', 'stable'} Choose the implementation variant, such as a sort algorithm or a plot type. |
na_position |
Optional Keyword only Default 'last' |
{'first', 'last'} Place missing values first or last in the result. |
sort_remaining |
Optional Keyword only Default True |
bool |
ignore_index |
Optional Keyword only Default False |
bool Give the resulting axis new integer labels where supported. |
key |
Optional Keyword only Default None |
callable Provide the lookup key, or a transformation callable for a sorting method. |
Returns
Series or None