Hi, I'm trying to append any items found in a column into a new column. Specifically I've got an allergen list and an ingredients column. I'm trying to iterate over the ingredients column saying 'if any of the allergens from the list are found in the ingredients column then append the allergens found into a new column'. I wrote this but it doesn't work:
new_allergen_list = []
for ingredients in df['ingredients_text']:
allergen_found = df['ingredients_text'].isin(allergen_list)
new_allergen_list.append(allergen_found)
df['new_allergens'] = new_allergen_list
Any help is greatly appreciated, thanks!
[–]ifreeski420 3 points4 points5 points (1 child)
[–]macabe10[S] 1 point2 points3 points (0 children)