Jun-23-2019, 03:55 PM
df['Location'].str.contains('Darley', regex=True, na=False)Look at result.
df['Location'].str.contains('Darley|Boston', regex=True, na=False)Now see True False values.
Wrap slicing operation to see result,as we have done in the multiply Boolean check before.
df[df['Location'].str.contains('Darley|Boston', regex=True, na=False)]str.contains can take regex as specify to be clear with
regex=True
.In regex
|
means or
.>>> import re >>> >>> s = 'foobar' >>> re.findall(r'foo', s) ['foo'] >>> re.findall(r'foo|bar', s) ['foo', 'bar']