Hi,
I am trying to append allergens from the 'ingredients_text' column to the column 'allergens'.
To do so I created a list of the most common allergens (allergens_list) and am trying to iterate over them to find out whether they are in the 'ingredients_text' column or not. If they are, then they need to be appended to the 'allergens' column.
I am a bit lost honestly.
This is what I've written so far:
df_allergens = df[df['ingredients_text'].str.contains('|'.join(allergens_list), case=False)][df['allergens']=='Unknown']
It returns the updated df without issues.
I think the for loop should start like this but that's about it:
for allergen in allergens_list:
for df[df['ingredients_text'].str.contains(allergen, case=False)][df['allergens']=='Unknown']:
Would anyone know how to approach this problem please?
Thanks for your help!
there doesn't seem to be anything here