pandas multiple string contains

Solutions on MaxInterview for pandas multiple string contains by the best coders in the world

showing results for - "pandas multiple string contains"
Charlotte
29 Nov 2020
1# credit to Stack Overflow user in the source link
2
3>>> df = pd.Series(['cat','hat','dog','fog','pet'])
4>>> searchfor = ['og', 'at']
5>>> df[df.str.contains('|'.join(searchfor))]
6
70    cat
81    hat
92    dog
103    fog
11dtype: object