【发布时间】:2021-03-09 11:25:23
【问题描述】:
input_df1: ID MSG
id-1 'msg1'
id-2 'msg2'
id-3 'msg3'
ref_df2: ID MSG
id-1 'msg1'
id-2 'xyzz'
id-4 'msg4'
我正在尝试根据以下条件生成输出数据帧:
-
如果 input_df 中的 'id' 和 'msg' 值都与 ref_df 中的值匹配 = 匹配
-
如果 input_df 中的 'id' 值在 ref_df 中不存在 = notfound
-
如果只有 input_df 中的 'id' 值与 ref_df 中的 'id' 值匹配 = not_matched
sample output: ID MSG flag
id-1 'msg1' matched
id-2 'msg2' not_matched
id-3 'msg3' notfound
我可以使用列表来做到这一点,但考虑到我要处理大量数据这一事实,性能很重要,因此我正在寻找一种更快的解决方案。 任何一点帮助将不胜感激 '''
【问题讨论】:
标签: python-3.x pandas list dataframe data-manipulation