pandas 1.4.2

ParametersReturns
rank(self, method: 'WindowingRankType' = 'average', ascending: 'bool' = True, pct: 'bool' = False, **kwargs)
versionadded

Parameters

method : {'average', 'min', 'max'}, default 'average'

How to rank the group of records that have the same value (i.e. ties):

  • average: average rank of the group

  • min: lowest rank in the group

  • max: highest rank in the group

ascending : bool, default True

Whether or not the elements should be ranked in ascending order.

pct : bool, default False

Whether or not to display the returned rankings in percentile form.

**kwargs :

For NumPy compatibility and will not have an effect on the result.

Returns

Series or DataFrame

Return type is the same as the original object with np.float64 dtype.

Calculate the rolling rank.

See Also

pandas.DataFrame.rank

Aggregating rank for DataFrame.

pandas.DataFrame.rolling

Calling rolling with DataFrames.

pandas.Series.rank

Aggregating rank for Series.

pandas.Series.rolling

Calling rolling with Series data.

Examples

This example is valid syntax, but we were not able to check execution
>>> s = pd.Series([1, 4, 2, 3, 5, 3])
... s.rolling(3).rank() 0 NaN 1 NaN 2 2.0 3 2.0 4 3.0 5 1.5 dtype: float64
This example is valid syntax, but we were not able to check execution
>>> s.rolling(3).rank(method="max")
0    NaN
1    NaN
2    2.0
3    2.0
4    3.0
5    2.0
dtype: float64
This example is valid syntax, but we were not able to check execution
>>> s.rolling(3).rank(method="min")
0    NaN
1    NaN
2    2.0
3    2.0
4    3.0
5    1.0
dtype: float64
See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /pandas/core/window/rolling.py#2352
type: <class 'function'>
Commit: