df_ordered_p_l = df.sort_values(['User', 'year', 'week', 'P/L', 'percentage'], ascending=[True, True,True, False, False]).groupby(['User', 'year', 'week']).agg(P_L_ordered = ('P/L',lambda x: list(x)), percentage_ordered = ('percentage', lambda x: list(x)) )
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter