先上代码
#导入padas和numpy库
import pandas as pd
import numpy as np
#读取文件内容
df1 = pd.read_excel(r'aaa.xlsx', sheet_name='Sheet1')
df2 = pd.read_excel(r'ccc.xlsx', sheet_name='Sheet1')
# print(df1)
# print(df2)
#以df1为基础,将df2的sumif结果合并到df1
df1['订单量'] = df2.姓名.apply(lambda x : df2.订单量.loc[df2.姓名 == x].sum())
print(df1)
分段执行