I have a pd series that contains
s = pd.Series(['cat, pet','dog, pet','dog','bird', 'bird, pet','tail', 'cat, tail'])
and I want to find all places where s
contains both of ['cat', 'pet']
I know that I want to find 'cat'
OR 'pet'
, so I just filter like:
search = ['cat', 'pet']
s[s.str.contains('|'.join(search))]
But what if I want to match 'cat'
AND 'pet'
??
I tried:
s[s.str.contains('&'.join(search))]
But it is not working for me :/