I am trying to filter a dataframe with a multi-index like the following.
import numpy as np
import pandas as pd
data = pd.DataFrame(np.random.rand(8),
index=[list('AABBCCDD'),
['M', 'F']*4])
data['Count'] = [1,2,15,17,8,12,11,20]
I would like to select all rows where the โCountโ for โMโ and โFโ inside a given external level index is greater than 10. So for the framework example, all rows โBโ and โDโ should be selected, but none of the other rows . The only way I can do this is to iterate over the external index, but since loops in pandas are almost never the best way to do what I think should be the best solution.
elphz source
share