I have a pandas data frame like the one below.
UsrId JobNos
1 4
1 56
2 23
2 55
2 41
2 5
3 78
1 25
3 1
I group by the data frame based on the UsrId
. The grouped data frame will conceptually look like below.
UsrId JobNos
1 [4,56,25]
2 [23,55,41,5]
3 [78,1]
Now, I'm looking for an in-build API that will give me the UsrId
with the maximum job count. For the above example, UsrId
-2 has the maximum count.
UPDATE:
Instead of the UsrID
with maximum job count, I want n
UserIds
with maximum job counts. For the above example, if n=2
then the output is [2,1]
. Can this be done?