Table Of Contents


Enter search terms or a module, class or function name.


DataFrameGroupBy.rank(method='average', ascending=True, na_option='keep', pct=False, axis=0)[source]

Provides the rank of values within each group


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

  • average: average rank of group
  • min: lowest rank in group
  • max: highest rank in group
  • first: ranks assigned in order they appear in the array
  • dense: like ‘min’, but rank always increases by 1 between groups

method : {‘keep’, ‘top’, ‘bottom’}, default ‘keep’

  • keep: leave NA values where they are
  • top: smallest rank if ascending
  • bottom: smallest rank if descending

ascending : boolean, default True

False for ranks by high (1) to low (N)

pct : boolean, default False

Compute percentage rank of data within each group



DataFrame with ranking of values within each group

Scroll To Top