dataFrame.column.stat — rankAvg()

Description

The rankAvg() method of the stat object returns an array containing the average ranks of the values in the selected column.

Signature

dataFrame.column(columnName).stat.rankAvg()
Scope
column
Family
stat
Returns
array

Argument

columnName (string)
The name of the column containing the values to assign ranks.

Returns

mask (array)
An array containing the average rank associated with each value in the selected column. Tied values receive the average of their ranks.

Note

When multiple values are equal, they are assigned the average of the ranks they occupy, consistent with the ranking method used by Excel's RANK.AVG function.

Example

// get the avg ranks of values of a column of the dataFrame
var mask = dataFrame.column('revenue').stat.rankAvg();

// add the ranks to the dataFrame
dataFrame.column('ranks').set(mask);