Using user defined function in groupby
You could do it simple and it should work like this:
def myfunc(df):
    return df.nlargest(3, 'values')[['values']].sum()

and then:
data_agg = df.groupby('date', as_index=False).apply(myfunc)

You decide if &quot;data_agg&quot; is the proper name then.
Good luck!