I had done this before, but I can't seem to find the way to do it again:
dfs=
month charges pl instrument_type total
01JUL2019-31JUL2019 1542.4266 2205.000 CDS 3747.4266
01JUL2019-31JUL2019 -5670.1898 0.000 EQ -5670.1898
01JUL2019-31JUL2019 25342.2627 -112535.000 FO -87192.7373
01OCT2020-31OCT2020 24769.4206 438663.500 FO 463432.9206
01OCT2020-31OCT2020 1821.6821 -2602.500 CDS -780.8179
01OCT2020-31OCT2020 -3267.2467 57404.043 EQ 54136.7963
I want to combine the month
column to a level show the dfs
as:
Expected output:
dfs=
month charges pl instrument_type total
01JUL2019-31JUL2019 1542.4266 2205.000 CDS 3747.4266
-5670.1898 0.000 EQ -5670.1898
25342.2627 -112535.000 FO -87192.7373
01OCT2020-31OCT2020 24769.4206 438663.500 FO 463432.9206
1821.6821 -2602.500 CDS -780.8179
-3267.2467 57404.043 EQ 54136.7963
I assumed this would be done by: dfs.set_index(['month','iunstrument_type'])
But it doesn't result in the desired output. I tried set_levels
which didn't work either.