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 expanding rank.

See Also

pandas.DataFrame.expanding

Calling expanding with DataFrames.

pandas.DataFrame.rank

Aggregating rank for DataFrame.

pandas.Series.expanding

Calling expanding with Series data.

pandas.Series.rank

Aggregating rank for Series.

Examples

This example is valid syntax, but we were not able to check execution
>>> s = pd.Series([1, 4, 2, 3, 5, 3])
... s.expanding().rank() 0 1.0 1 2.0 2 2.0 3 3.0 4 5.0 5 3.5 dtype: float64
This example is valid syntax, but we were not able to check execution
>>> s.expanding().rank(method="max")
0    1.0
1    2.0
2    2.0
3    3.0
4    5.0
5    4.0
dtype: float64
This example is valid syntax, but we were not able to check execution
>>> s.expanding().rank(method="min")
0    1.0
1    2.0
2    2.0
3    3.0
4    5.0
5    3.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/expanding.py#609
type: <class 'function'>
Commit: