Premium problem97. Rank Senders by Volume

Medium Locked

emails has columns email_id, from_user and to_user.

Count the emails each user sent and return a DataFrame with columns from_user, sent and rank, ordered from most to least active. Ties share a rank (the busiest two users both rank 1, and the next ranks 3), and tied users are listed alphabetically. Renumber the index from 0.

Input

   email_id from_user to_user
0         1       zoe       x
1         2       ann       y
2         3       ann       z
3         4       bob       x
4         5       zoe       y
5         6       cid       z

Output

  from_user  sent  rank
0       ann     2     1
1       zoe     2     1
2       bob     1     3
3       cid     1     3

Premium problem

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

Implement solve(...)