get max index in a agg function and select value of another column

PHOTO EMBED

Wed Feb 09 2022 01:16:05 GMT+0000 (Coordinated Universal Time)

Saved by @Milados

df.groupby(['User', 'year', 'week']).apply(lambda x: x.loc[x['P/L'].idxmax(), 'symbol'])
content_copyCOPY

http://localhost:8888/notebooks/Untitled.ipynb