[Python] Find maximum value of a column and return the corresponding row values using Pandas

Discussão em 'Python' iniciado por Stack, Fevereiro 22, 2025.

  1. Stack

    Stack Membro Participativo

    Country Place Value
    US NewYork 562
    US Michigan 854
    US Illinois 356
    UK London 778
    UK Manchester 512
    Spain Madrid 509
    India Mumbai 196
    US Kansas 894
    UK Liverpool 796
    Spain Barcelona 792


    Using Pandas I am trying to find the Country and Place with the maximum value.

    This returns the maximum value:

    data.groupby(['Country','Place'])['Value'].max()


    But how do I get the corresponding Country and Place name?

    Continue reading...

Compartilhe esta Página