Selecting columns from pandas MultiIndex
The most straightforward way is with .loc: >>> data.loc[:, ([‘one’, ‘two’], [‘a’, ‘b’])] one two a b a b 0 0.4 -0.6 -0.7 0.9 1 0.1 0.4 0.5 -0.3 2 0.7 -1.6 0.7 -0.8 3 -0.9 2.6 1.9 0.6 Remember that [] and () have special meaning when dealing with a MultiIndex object: (…) a … Read more