I want to print the 3rd highest value along with the 'Id' as the pic

Question:

From here I want to print the 3rd highest value along with the ‘Id’. A help would be appreciated

Most_Calori_Burner.nlargest(3)

series

Asked By: Arijit Koley

||

Answers:

TRy this,

df.groupby('Id')['Calories'].sum().sort_values(ascending=False).reset_index().iloc[2]
  • Sort your dataframe in descending order
  • Reset index and take 3rd value.
Answered By: Mohamed Thasin ah
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.