【发布时间】:2021-09-06 13:46:04
【问题描述】:
我想检查某些关键字是否存在于另一个数据框中。 如果 df2['name'] 中的列包含 df1['keywords'] 中的关键字,则在满足 df1['app'] 条件的每一行中在 df2 中创建一个新列
df1 = pd.DataFrame({'keywords': ['Excel', 'Agir', 'ILAB', 'GPO', 'DTAV', 'BI', 'Twin'],
'app': ['Microsoft Excel', 'App Agir', 'Laborátório Digital', ' Gestão do processo', 'Digital', 'Painel BI', 'Digital']})
df2 = pd.DataFrame({'name': ['Word', 'app Excel', 'Agir', 'GPO', 'Painel BI', 'Bob', 'Revit', 'Autocad', 'Acces']})
在 df2 中,我需要创建一个新列并填写匹配结果
例如,关键字“Excel”出现在 df2 的第二行,所以我想在 df2['new column'] 列中填充与 df1['app'] 中关键字 Excel 对应的行,那就是'Microsoft Excel
谢谢
【问题讨论】:
-
到目前为止你尝试了什么?