[英]How to check if elements of a list of strings in a pandas column are present in another column
I have a pandas data frame (showing values of one of the rows) as below.我有一个 pandas 数据框(显示其中一行的值),如下所示。 In the annotation column, I have a list of strings which I want to check in the note_sentence column which contains sentences.
在注释列中,我有一个字符串列表,我想在包含句子的 note_sentence 列中检查这些字符串。
I used the below code to check the existence but it is unable to capture the existence of strings in the sentences.我使用下面的代码来检查是否存在,但它无法捕获句子中字符串的存在。
df_feature_case_notes['Exists'] = df_feature_case_notes.apply(lambda x: 'Yes' if x['annotation'] in x['note_sentence'] else 'No',axis=1)
How can I fix my code?如何修复我的代码?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.