Skip to main content
Version: 1.5.0

Expr.rank

def rank(
method: td_RankMethod = 'average',
descending: bool = False,
seed: int | None = None,
) -> Expr

Categories: aggregation

Compute the rank of the element values. Multiple rank types are available.

Parameters

parameter
method

the ranking type: 'average' (default), 'dense', 'max', 'min', 'ordinal' or 'random'.

parameter
descending

if the order is ascending (default) or descending.

parameter
seed

random seed when using 'random' rank type.

Examples

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.col("val"), td.col("val").rank("max").alias("rank"))
>>>
┌──────┬──────┐
│ val ┆ rank │
------
│ f64 ┆ u32 │
╞══════╪══════╡
-1.01
0.02
1.13
2.04
│ inf ┆ 5
│ null ┆ null │
│ NaN ┆ 6
└──────┴──────┘