DataFrameGroupBy.rank()

pandas.core.groupby.DataFrameGroupBy.rank

DataFrameGroupBy.rank(axis=0, method='average', numeric_only=None, na_option='keep', ascending=True, pct=False)

Compute numerical data ranks (1 through n) along axis. Equal values are assigned a rank that is the average of the ranks of those values

Parameters:

axis: {0 or ‘index’, 1 or ‘columns’}, default 0

index to direct ranking

method : {‘average’, ‘min’, ‘max’, ‘first’, ‘dense’}

  • average: average rank of group
  • min: lowest rank in group
  • max: highest rank in group
  • first: ranks