groupby+rank 分组+排序 df['row_num']=df['a'].groupby(df['b']).rank(ascending=False,method='max') 转载于:https://www.cnblogs.com/fatcici2017/p/10348904.html