I have a list and a dataframe with one column named Description that looks like this:
my_list = ['dog','cat','bird'...]
df
| Description |
|three_legged_dog0named1_Charlie|
| catis_mean |
| 1hippo_stepped-on_an_ant |
I want to write a for loop that loops through each row in df and check whether it contains an element in list, if it does, print the element.
normally I'd use search(), but I don't know how it works with a list. I could write a for loop that captures all the cases but I don't want to do that. Is there another way around?
for i in df['Description']:
if i is in my_list:
print('the element that is in i')
else:
print('not in list')
the output should be:
dog
cat
not in list