Reputation: 18638
These are the types for my DataFrame;
count int64
word object
cat1 bool
cat2 object
cat3 bool
dtype: object
How do I do a filter for boolean values from 'cat1' and 'cat2'?
Something like...
data[(data['cat1'].bool() == FALSE) & (data['cat3'].bool() == FALSE)]
Upvotes: 2
Views: 6613
Reputation: 376
You can simply do this,
data[(data['cat1']==False) & (data['cat3']==False)]
Example:
test = pd.DataFrame({'word':'','cat1':bool(),'cat2':'','cat3':bool()},index=[])
test.loc[0]=['test1',True,'try',False]
test.loc[1]=['test1',False,'try',False]
test[(test['cat1']==False) & (test['cat3']==False)]
Upvotes: 0
Reputation: 393863
Just do:
data[(data['cat1'] == FALSE) & (data['cat2'] == FALSE)]
cat2
is an object
dtype
so it is probably a string, I think you want:
data[(data['cat1'] == FALSE) & (data['cat3'] == FALSE)]
otherwise if it really is string values then you can do
data[(data['cat1'] == FALSE) & (data['cat2'] == 'FALSE')]
or
data[(data['cat1'] == FALSE) & (data['cat2'].str.contains('FALSE'))]
Upvotes: 1