I need to query a Pandas Dataframe based on multiple criteria on the Index and the Column. Please have a look at my data below. 'Country' and 'Surname' are two separate indices, while 'Name', 'Score', 'Type' are columns.
y = pd.DataFrame({'Name':['Nikhil', 'Ankit', 'Keval', 'Darpan', 'Rajesh', 'John', 'Lynda'],
'Score':[89,92,96,82,95,98,97],
'Type':['Fat','Slim','Fat','Slim','Fat','Slim','Slim'],
'Country':['India','USA','Denmark','Australia','Italy','China','Israel'],
'Surname':['Sharma','Sharma','Patel','Shah','Sharma','Sharma','Sharma']}
).set_index('Country').set_index('Surname', append=True)
I want to select data which meets following criteria:
- Country should neither be India nor be USA
- Surname should be Sharma
- Score should be equal to or above 90
- Type should be Slim
