How does python pandas compare the inclusion relationship between two columns of data and write the results in Table 1?

Table 1 add column matching Table 2 key _ word, if Table 1 add contains Table 2 key_word, write group, in Table 1 column 4, if not, mark "not included". PS: I also measured with iteration, Cartesian product also tried, but did not achieve the desired results, please gods, help solve it, thank you! Please take a look at my code below. It"s a piece of cake, which makes you laugh.


it is best not to use for loops.

df1['group'] = df1['add'].apply(lambda x: df2.loc[[y in x for y in df2['key_word']],'group']).stack().reset_index(name='group')['group']

Update:
another way to deal with cases that are not included

def match_group(x):
    for y in df2['key_word']:
        if y in x:
            return y
    return ''

df1['group'] = df1['add'].apply(match_group)
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e438f5-44a61.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e438f5-44a61.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?