If I have a df:
VLA
0 40
1 200
and then a multi-index that looks like this:
stuff1 ... stuff2
p1 p1 p2 ... p3 p4 p4
dates ...
2019-12-01 596.973988 1268.966237 0.969522 ... 2.344248 1.365735 2.903094
2019-12-02 1.100081 2.338402 1.249667 ... 2.815914 1.387209 2.948740
How would I create a dataframe that takes VLA as an upper index on the second dataframe so it would look like this:
VLA 40 ... 200
stuff1 ... stuff2
p1 p1 p2 ... p3 p4 p4
dates ...
2019-12-01 596 1268 0.969522 ... 2.344248 1.365735 2.903094
2019-12-02 1.100081 2.338402 1.249667 ... 2.815914 1.387209 2.948740
print (df.columns.levels[0])
Index(['stuff1', 'stuff2', 'stuff3', 'stuff4', 'stuff5', 'stuff6', 'stuff7'], dtype='object')
print (lvl0.map(d)
Float64Index([ 43.0, 43.0, 43.0, 43.0, 43.0, 43.0, 43.0, 43.0, 210.0,
210.0, 210.0, 210.0, 210.0, 210.0, 210.0, 210.0, nan, nan,
nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan, nan],
dtype='float64')
print (df.columns.levels[0])?Index(['stuff1', 'stuff2', 'stuff3', 'stuff4', 'stuff5', 'stuff6', 'stuff7'], dtype='object')- its worth noting that all these are on a VLA specific level, i.e: if there is 2 entries in VLA then there are 2 lots of stuff1-7