I have some trade data as seen in the image.
There can be many entries for a single instant in time. I would like to do some calculations based on PRICE and SIZE at each moment in time. I would like to do something like:
total_size = eur_jpy_order.groupby(['TIMESTAMP', 'BUY_SELL_FLAG']).sum()
avg_price = eur_jpy_order.groupby(['TIMESTAMP', 'BUY_SELL_FLAG']).mean()
and then take just have a dataframe with TIMESTAMP, BUY_SELL_FLAG, total_size and avg_price, with a single entry for each time step. I can't find a simple way of doing this. Could anyone advise?