Rank with ties
A pandas exercise from Pandasdrill. Solve it with a Python editor in your browser running real pandas, and it is checked the moment you submit.
The task
Rank the reps by `revenue`, highest first, so the top rep gets 1. Tied reps share the lower rank number (two reps tied for second both get 2, and the next rep gets 4).
What this exercise teaches
By default rank gives ties the average of their positions, such as 2.5. method="min" gives them the lowest position instead, the way sports tables do, and ascending=False makes the largest revenue rank 1.
A hint if you get stuck
rank has ascending and method parameters. method="min" gives tied values the smallest rank in their group.
This exercise is part of Pro
Pro unlocks all 45 exercises, with worked solutions and progress saved to your account. The free exercises work without an account.
You create a free account first, so Pro is attached to it.
Monthly is charged today and then every month until you cancel, in one click from your account page. Lifetime is one payment with no renewals. Full refund within 14 days of paying.