I am trying to filter the following dataframe from the view seen in 'Initial dataframe' to what is displayed in 'Desired output'
Initial dataframe
name group subject score class_size
Steve classrm_A maths 98.22 20
John classrm_A maths 76.87 30
Mary classrm_C science 77.25 26
Steve classrm_B science 65.28 32
Mary classrm_A english 86.01 16
John classrm_F science 96.55 25
Return rows for unique 'name' values where score' is greatest and 'class_size' is equal or greater than 25.
Desired output:
name group subject score class_size
Steve classrm_B science 65.28 32
Mary classrm_C science 77.25 26
John classrm_F science 96.55 25
Here is what I have attempted so far.....
min_class = df["class_size"] >= 25
df = df["min_class "]
df = df.groupby(['name']).max('score')
Any help would be greatly appreciated.