pandas rank vs dense_rank code example Example: dense rank in pandas df['Rank'] = df.Year.rank(method='dense').astype(int) df