df.groupby(['job']).apply(lambda x: (x.groupby('source') .sum() .sort_values('count', ascending=False)) .head(3))
Here is what the above code is Doing:
1. Grouping the df by job
2. Applying a lambda function to each job group
3. Grouping the df by source
4. Summing the count column
5. Sorting the df by count
6. Taking the top 3 rows