Given that I have the following pandas DataFrame:
arrays = [np.array(['bar', 'bar', 'baz', 'baz', 'foo', 'foo', 'qux', 'qux']),
np.array(['one', 'two', 'one', 'two', 'one', 'two', 'one', 'two']),
np.array([0.01, 0.2, 0.3, -0.5, 0.6, -0.7, -0.8, 0.9])]
tuples = list(zip(*arrays))
df_index = pd.MultiIndex.from_tuples(tuples, names=['A', 'B', 'measure'])
df = pd.DataFrame(np.random.randn(8, 4), index=df_index)
print(df)
How can I filter all the values where for example the measure column (which is part of the index) is greater than 0.2?
I have tried:
df.loc[:,:,0.1:0.9]
(and other variations of this, but I get the error "IndexingError: Too many indexers"
Thanks, Gerald