Pandas max value index

后端 未结 3 1713
耶瑟儿~
耶瑟儿~ 2020-11-27 18:17

I have a Pandas DataFrame with a mix of screen names, tweets, fav\'s etc. I want find the max value of \'favcount\' (which i have already done) and also return the screen n

3条回答
  •  攒了一身酷
    2020-11-27 19:08

    Use argmax() idxmax() to get the index of the max value. Then you can use loc

    df.loc[df['favcount'].idxmax(), 'sn']
    

    Edit: argmax() is now deprecated, switching for idxmax()

提交回复
热议问题