I have the following list:
list = ['abc', 'ace', 'aei']
And I have DataFrame:
df = pd.DataFrame({"A": ['abc','abd','abe','acd','ace','aci'], "B": ""})
I want write a function that will, for each value in df['A'], check for any match in the list. If a match exists, add "match" for that value in df['B']. So far the for loops I've tried don't seem to be working. For example:
for el in df['A']:
if el in list:
df['B'] = "match"
else:
pass
This populates every row of df['B'] with "match". Other efforts have not populated df['B'] when there is a match.
Thanks!