Reputation: 167
I have the DataFrame, where I am trying to add a new "rank" column to determine the price rating relative to the "name" and "country" columns by comparing prices (column 'price'). But with no success. I need the following result, screenshot below. Help please, I will be grateful
Upvotes: 0
Views: 168
Reputation: 6564
Try this:
df['rank'] = df.groupby('name')['price'].rank(ascending=False)
Upvotes: 2