如何遍历一个数据框的每个值并检查是否包含另一个数据框列中的单词?
a = pd.DataFrame({'text': ['the cat jumped over the hat', 'the pope pulled on the rope', 'i lost my dog in the fog']})
b = pd.DataFrame({'dirty_words': ['cat', 'dog', 'parakeet']})
a
text
0 the cat jumped over the hat
1 the pope pulled on the rope
2 i lost my dog in the fog
b
dirty_words
0 cat
1 dog
2 parakeet
我想获取一个只包含这些值的新数据框:
result
0 the cat jumped over the hat
1 i lost my dog in the fog