I have a pandas dataframe defined as follows:
import pandas as pd
headers = [\'Group\', \'Element\', \'Case\', \'Score\', \'Evaluation\'
My Take
g = df.set_index('Group').groupby(level='Group', group_keys=False)
result = g.apply(
pd.DataFrame.nlargest, n=1, columns='Score'
)
def f(x):
x = 'value' if x == 'Score' else x
return 'Max_score_' + x.lower()
result.drop('Evaluation', 1).rename(columns=f).assign(
Min_evaluation=g.Evaluation.min().values).reset_index()
Group Max_score_element Max_score_case Max_score_value Min_evaluation
0 A 1 y 9.19 0.41
1 B 2 x 9.12 0.10