I have a CSV that produces a Dataframe in the following format
--------------------------------------------------------------
|Date | Fund | TradeGroup | LongShort | Alpha | Details|
--------------------------------------------------------------
|2018-05-22 |A | TGG-A | Long | 3.99 | Misc |
|2018-05-22 |A | TGG-B | Long | 4.99 | Misc |
|2018-05-22 |B | TGG-A | Long | 5.99 | Misc |
|2018-05-22 |B | TGG-B | Short | 6.99 | Misc |
|2018-05-22 |C | TGG-A | Long | 1.99 | Misc |
|2018-05-22 |C | TGG-B | Long | 5.29 | Misc |
--------------------------------------------------------------
What I would like to Do is, Group TradeGroups together and convert Fund to columns. So, the final dataframe should look like this:
--------------------------------------------------------
|TradeGroup| Date | A | B | C |
--------------------------------------------------------
| TGG-A |2018-05-22 | 3.99 | 5.99 | 1.99 |
| TGG-B |2018-05-22 | 4.99 | 6.99 | 5.29 |
--------------------------------------------------------
Also, I don't really care about the LongShort Column and Details Column. So, it's okay if they're dropped. Thanks!!
I have tried df.pivot() but it doesn't give the required format
df.set_index(['Date','TradeGroup','Fund']).unstack(level=2)['Alpha']