[Python] Count maximum value in each group with Pandas

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

  1. Stack

    Stack Membro Participativo

    Suppose I have a dataframe df looking like

    school score student_id
    0 1 100.0 965
    1 2 64.0 1483
    2 2 100.0 1055
    3 2 68.0 1806
    4 1 100.0 971


    I want to find how many maximum scores in each group and get something like this:

    school count_max
    1 2
    2 1


    How can I do it?

    Continue reading...

Compartilhe esta Página