Q:

select from multilevel columns with multiple lists

import pandas as pd
import numpy as np
np.random.seed(0)

idx = pd.MultiIndex.from_product([list('BAC'), list('AB'), ["high", "low"]], names=['level_0', 'level_1', 'level_2'])
df = pd.DataFrame(np.random.randn(2, len(idx)), columns=idx)

I am trying to select the column with: level_0 = B and A,  level_1 = B, and level_2 = high.
I can select columns with
list = ["A", "B"]

df.reindex(columns=list, level=0)

But I can't figure out how to add the next level slice.

A:

pd.IndexSlice comes to your rescue
In [21]: df.loc[:,pd.IndexSlice[(["A","B"],"B","high")]]
Out[21]:
level_0         B         A
level_1         B         B
level_2      high      high
0        0.978738  0.950088
1        0.443863  0.313068

