Having a dataframe as follows:
df= pd.DataFrame({'category':['Fishing','Refrigeration','store'],'synonyms_text':['seafood','foodlocker',' food']})
And a list as follows:
list_desc=['FOOD', 'GROWERS', 'INTERNATIONAL']
How can I iterate over the list_desc
to create a dynamic regular expression to be used in the dataframe?
for word in list_desc:
print(word.lower())
df_tmp= df.loc[df['synonyms_text'].str.contains(r'\bfood\b')]
Where food
has to be substituted by word
variable.
Thanks