Index return tuple and .max () value?

I am trying to return an index tuple (people names below) and the maximum value for the "%" column below. When I create a Dataframe and try

df['%'].max() 

Pandas always returns a value, not an index. However, I want to create a tuple from a pair of index key values ​​and the maximum value in the "%" column. I'm sure this is a newbie question, thanks for helping me!

Here are some sample data:

  Points_Scored Possible_Points % Favoriate Food Jan 60 200 0.3 Pudding Jane 87 200 0.435 Pizza Bob 54 200 0.27 Salad Bubba 42 200 0.21 Salsa Jack 98 200 0.49 Avacodo John 45 200 0.225 Bacon Mike 63 200 0.315 Tacos Victor 8 200 0.04 Lettuce 
+5
source share
1 answer

Here is one way:

 df['%'].idxmax(), df['%'].max() 
+8
source

Source: https://habr.com/ru/post/1263627/


All Articles