I'd like to find text in one field of a pandas dataframe ("text") based on another field ("words") of it.
#import re
import pandas as pd
df = pd.DataFrame([['I like apple pie','apple'],['Nice banana and lemon','banana|lemon']], columns=['text','words'])
df['text'] = df['text'].str.replace(r''+df['words'].str, '*'+group(0)+'*')
df
I'd like to mark the found words with *.
How can I do that?
The desired output is:
I like *apple* pie
Nice *banana* and *lemon*