I want to print the 3rd highest value along with the 'Id' as the pic
Question:
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.
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.