From here I want to print the 3rd highest value along with the 'Id'. A help would be appreciated
Most_Calori_Burner.nlargest(3)
CodePudding user response:
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.