I have the following data: inputdata = [[1,’long’,30.2,’Win’],[1,’long’,-12.4,’Loss’], [2,’short’,-12.3,’Loss’],[1,’long’,3.2,’Win’], [3,’short’,0.0,’B/E’],[3,’short’,23.2,’Win’], [3,’long’,3.2,’Win’],[4,’short’,-4.2,’Loss’]] datadf = DataFrame(columns=[‘AssetId’,’Direction’,’PnL’,’W_L’], data = inputdata) datadf AssetId Direction PnL W_L 0 1 long 30.2 Win 1 1 long -12.4 Loss 2 2 short -12.3 Loss 3 1 long 3.2 Win 4 3 short 0.0 B/E 5 3 short 23.2 Win 6 3 long […]

Categories

## aggregate dataframe horizontally

- Post author By Full Stack
- Post date May 29, 2020
- No Comments on aggregate dataframe horizontally

- Tags 'Loss']] datadf = DataFrame(columns=['AssetId', 'PnL', 'W_L'], "12.3", "short", "win", 0.0, 1, 12.4, 2, 23.2, 3, 3.2, 30.2, 4, 4 ["2", b.E, but I would have to fill my aggregation data frame field by field, data = inputdata) datadf AssetId Direction PnL W_L 0 1 long 30.2 Win 1 1 long -12.4 Loss 2 2, direction, dtype: int64 This produces the necessary data, I have the following data: inputdata = [[1, is there a better way to achieve this goal?, Long> { }, loss, more stats to be added: Stat Long Short Total 0 Trades 4 4 8 1 Won 3 1 4 2 Lost 1 2, which seems cumbersome and I am not even sure how to get the exact value into each row/column. Based on this example