Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Return Tuple of Index and .max() Value?

I'm trying to return a tuple of the index (the people names below) and the max value for the '%' column below. When I create a Dataframe and try

df['%'].max()

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

Here's 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
like image 688
Python_Learner_DK Avatar asked Jan 31 '17 16:01

Python_Learner_DK


1 Answers

Here is one way:

df['%'].idxmax(), df['%'].max()
like image 68
Zeugma Avatar answered Oct 02 '22 00:10

Zeugma