I wont to search a df.column for a partial strings that I saved in a series and wont to create a new column with the str that I found in each row. A part of my question was solved by pandas: test if string contains one of the substrings in a list:
For example, say I have the series s = pd.Series(['cat','hat','dog','fog','pet']), and I want to find all places where s contains any of ['og', 'at'], I would want to get everything but pet.
The solution is:
>>> searchfor = ['og', 'at']
>>> s[s.str.contains('|'.join(searchfor))]
0 cat
1 hat
2 dog
3 fog
dtype: object
but I would like to get
pet contains
0 cat at
1 hat at
2 dog og
3 fog og
dtype: object