I need to search a df column and return all substrings from a list.
myList= ['a cat', 'the dog', 'a cow']
example df
'col A'
there was a cat with the dog
the cow was brown
the dog was sick
this splits the words in the list and only returns single words
df['col B'] = df['col A'].apply(lambda x: ';'.join([word for word in x.split() if word in (myList)]))
also tried to add in an np any...
df['col B'] = df['col A'].apply(lambda x: ';'.join(np.any(word for word in df['col A'] if word in (myList))))
need to return
'col B'
a cat;the dog
NaN
the dog