我在“作业摘要”列下的每一行中都有字符串,技能和熊猫数据框的列表,每行都有说明。我想查看“技能”中的任何字符串是否是“作业摘要”列中的子字符串。如果存在匹配项,则使匹配的字符串出现在标记为Matches的列中。如果有多个,则应显示为字符串列表。现在我有了它,它告诉我是非题,但我希望单词本身匹配。
在下面查看我目前的情况
#Sample list (Real list is much longer)
Skills=['Science', 'Management','Equipment','Analysis']
skills=list(map(str.lower,skills))
joined='|'.join(skills)
df['Matches']=df['Job Summary'].str.contains(joined)
df ['Matches']的结果告诉我是非是。我想要匹配的词
答案 0 :(得分:0)
使用str.findall
df=pd.DataFrame({'Job Summary':['Science Equipment','Analysis is Management']})
df['Job Summary'].str.findall('|'.join(Skills))
Out[95]:
0 [Science, Equipment]
1 [Analysis, Management]
Name: Job Summary, dtype: object