rank function

The rank function returns the values of a column in ascending alphabetic order. By default missing values are considered in the ranking.


Parameters

rank(column, usemissing)

Parameter

Description

column

The values of the specified column will be placed in ascending order. Column is a mandatory parameter.

usemissing

To not consider missing values, this parameter can be set to False. By default, its value is True.


Example - rank(column, usemissing)

The following examples use the Sales_2017 dataset, from which we have removed some values in the Sales attribute.

Description

Screenshot

In the first example, we have a series of missing values in the Day attribute in our dataset, which we want to fill.

If we enter the formula rank($"Sales") the rank of each Sales value, in alphabetical order will be displayed, with missing values placed at the top of the list.

If, however, we do not want to consider missing values in the ranking, the second parameter, usemissing, must be set to false with the formula rank($"Sales", False).