我有两个excel文件,我将它们命名为:源.xlsx,输出.xlsx。在
我需要使用Caller ID列匹配数据源.xlsx到svc_列输出.xlsx
如果不匹配,或者使用Caller ID列的值为“NULL”,我可以使用的adsl列源.xlsx与端口列匹配输出.xlsx。在
如果有匹配项,那么我应该忽略端口并写入呼叫者ID
中的数据源.xlsx如下所示:
Caller ID adsl Comparison Result
NULL 2/12 Not Match
11111111 2/267 Match
22222222 4/243 Match
22222222 2/117 Possible Match
中的数据输出.xlsx如下所示:
^{pr2}$我的预期输出是从写入数据源.xlsx到输出.xlsx:
svc_no Caller ID port Comparison Result
22222222 22222222 4/243 Match
11111111 11111111 2/267 Match
22222222 22222222 2/117 Possible Match
NULL NULL 2/12 Not Match
我尝试使用:
df = read_excel('source.xlsx')
df1 = read_excel('output.xlsx')
df = df['Caller ID'].isin(df1['svc_no'])]
df['Caller ID'] = df1['Caller ID']
df1.to_excel('output.xlsx')
但是它不匹配并且随机写入。在
这是一种方法。在
相关问题 更多 >
编程相关推荐