import pandas as pd
lst = ['abc', 'ace', 'aei']
dct = {"A": ['abc','abd','abe','acd','ace','aci'], "B": ""}
if len(list(set(lst) & set(dct['A']))) != 0:
dct['B'] = 'match'
print (dct)
Output:
{'A': ['abc', 'abd', 'abe', 'acd', 'ace', 'aci'], 'B': 'match'}
If you still wish to use pandas:
import numpy as np
import pandas as pd
lst = ['abc', 'ace', 'aei']
dct = {"A": ['abc','abd','abe','acd','ace','aci'], "B": ""}
df['B'] = np.where(df['A'].isin(lst), 'match', '')
For partial matches:
lst = ['abc']
dct = {"A": ['abcdef','abd','abe','acd','ace','aci'], "B": ""}
if len([v for v in lst if v in " ".join(dct['A'])]) != 0:
dct['B'] = 'match'
Output:
{'A': ['abcdef', 'abd', 'abe', 'acd', 'ace', 'aci'], 'B': 'match'}
OP request:
lst = ['abc', 'ace', 'aei']
dct = {"A": ['abcdef','aei','abe','acd','ace','aci'], "B": []}
for test in lst:
for val in dct['A']:
if test in val:
dct['B'].append('match')
else:
dct['B'].append('nomatch')
print (dct)
Output:
{'A': ['abcdef', 'aei', 'abe', 'acd', 'ace', 'aci'], 'B': ['match', 'nomatch', 'nomatch', 'nomatch', 'nomatch', 'nomatch', 'nomatch', 'nomatch', 'nomatch', 'nomatch', 'match', 'nomatch', 'nomatch', 'match', 'nomatch', 'nomatch', 'nomatch', 'nomatch']}