import numpy as np
import pandas as pd
df=pd.DataFrame(data=np.array([['A','A','B','B','B'],['yes','no','yes','no','yes'],[1,1,1,1,1]]).T,columns=['letter','yn','ones'])
df
letter | yn | ones | |
---|---|---|---|
0 | A | yes | 1 |
1 | A | no | 1 |
2 | B | yes | 1 |
3 | B | no | 1 |
4 | B | yes | 1 |
df.loc[(df.letter=='A')&df.yn.str.contains('y')]
letter | yn | ones | |
---|---|---|---|
0 | A | yes | 1 |