Pandas rank by column value [duplicate]
Here's one way to do it in Pandas-way
You could groupby
on Auction_ID
and take rank()
on Bid_Price
with ascending=False
In [68]: df['Auction_Rank'] = df.groupby('Auction_ID')['Bid_Price'].rank(ascending=False)In [69]: dfOut[69]: Auction_ID Bid_Price Auction_Rank0 123 9 11 123 7 22 123 6 33 123 2 44 124 3 15 124 2 26 124 1 37 125 1 1