I know similar questions have been asked but I can't seem to find a solution to this one.
With the following code I can filter out using the columns and the first index but not the second.
import pandas as pd
import numpy as np
ix = pd.MultiIndex.from_product([ ['foo', 'bar'], ['baz',
'can']], names=['a', 'b'])
data = np.arange(len(ix))
df = pd.DataFrame(data, index=ix, columns=['values'])
df['values2']=[1,4,5,6]
print(df)
the resulting output is as follows:
Notice how the last line, does not work
df.loc['foo','can']['values2'] # works
df.loc['foo']['values2'] # works
df.loc['foo','can'][:] # works
df.loc['foo',:][:] # works
df.loc[:,'can'][:] # does not work.