pandas.api.typing.SeriesGroupBy.rank
pandas 3.1.1 · GroupBy · method
Assign positions in sorted order and choose how to handle ties.
Call syntax
pd.api.typing.SeriesGroupBy.rank(method='average', ascending=True, na_option='keep', pct=False)Run the example
Edit the example and select Run Python to see the result.
Parameters
| Parameter | Requirement | Accepted values and behavior |
|---|---|---|
method |
Optional Positional or keyword Default 'average' |
{'average', 'min', 'max', 'first', 'dense'} Choose the algorithm used to calculate, align, or fill the result. |
ascending |
Optional Positional or keyword Default True |
bool Choose ascending or descending order. Some sorting methods take one flag per sort key. |
na_option |
Optional Positional or keyword Default 'keep' |
{'keep', 'top', 'bottom'} |
pct |
Optional Positional or keyword Default False |
bool Express ranks or results as fractions where the API supports this option. |
Returns
DataFrame