[Python] How to find the most frequent value for each id

Discussão em 'Python' iniciado por Stack, Maio 4, 2025.

  1. Stack

    Stack Membro Participativo

    Let's say, I have number A and they call several people B

    A B

    123 987
    123 987
    123 124
    435 567
    435 789
    653 876
    653 876
    999 654
    999 654
    999 654
    999 123


    I want to find to whom the person in A has called maximum times and also the number of times.

    OUTPUT:

    A B Count
    123 987 2
    435 567 or 789 1
    653 876 2
    999 654 3


    How one can think of it is,

    A B
    123 987 2
    124 1
    435 567 1
    789 1
    653 876 2
    999 654 3
    123 1


    Can somebody help me out on how to do this?

    Continue reading...

Compartilhe esta Página