I have a MultiIndex dataframe with 200 columns. I would like to select a specific column from that. Suppose df is some part of my dataframe:
df=
a b
l h l h l h l
cold hot hot cold cold hot hot
2009-01-01 01:00:00 0.1 0.9 0.4 0.29 0.15 0.6 0.3
2009-01-01 02:00:00 0.1 0.8 0.35 0.2 0.15 0.6 0.4
2009-01-01 03:00:00 0.12 0.7 0.3 0.23 0.23 0.8 0.3
2009-01-01 04:00:00 0.1 0.9 0.33 0.24 0.15 0.6 0.4
2009-01-01 05:00:00 0.17 0.9 0.41 0.23 0.18 0.75 0.4
I would like to select the values for this column[h,hot].
My output should be:
df['h','hot']=
a b
2009-01-01 01:00:00 0.9 0.6
2009-01-01 02:00:00 0.8 0.6
2009-01-01 03:00:00 0.7 0.8
2009-01-01 04:00:00 0.9 0.6
2009-01-01 05:00:00 0.9 0.75
I would appreciate any guidance on how I could select that.
df['b','h','hot']should just work here for hierarchical columnslist(df.columns). This will help us see if there are errant spaces...df['b','h','hot']works for me, if it doesn't then postdf.info()andprint(df.columns.tolist()to see what the real column names are