Premium problem107. Rank Guests Oldest First

Easy Locked

guests has columns guest_id, nationality, gender and age.

Add a rank column where the oldest guest ranks 1. Guests of the same age share a rank and the ranks after a tie are skipped, so two guests tied at 1 are followed by rank 3. Return all the original columns plus rank, sorted by rank then guest_id, with the index renumbered from 0.

Input

   guest_id nationality gender  age
0         1          FR      f   41
1         2          DE      m   55
2         3          IT      f   55
3         4          ES      m   30

Output

   guest_id nationality gender  age  rank
0         2          DE      m   55     1
1         3          IT      f   55     1
2         1          FR      f   41     3
3         4          ES      m   30     4

Premium problem

This one's part of Premium. Unlock the full Pandas track plus every other premium problem on the site.

Implement solve(...)