pandas.Series.sort_values

pandas 3.1.1 · Series and accessors · method

Order items by one or more data values, controlling missing-value placement.

Call syntax

Series.sort_values(…) Full signature
Series.sort_values(
    *,
    axis=0,
    ascending=True,
    inplace=…,
    kind='quicksort',
    na_position='last',
    ignore_index=False,
    key=None,
)

Run the example

Edit the example and select Run Python to see the result.

Parameters

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

ascending Optional
Keyword only
Default True
bool or list 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' or 'last'}

Place missing values first or last in the result.

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