Python处理数据:匹配两个Excel文件数据
m0_70047537:
大神好,可以帮忙看看这个是什么原因吗,为什么会报错但是生成的excel是有来的,[code=python]
# 读取从系统导出的
total_table_org = pd.read_excel('Data.xlsx',sheet_name='Export')
total_table = total_table_org[total_table_org['Org'] != "PM"]
# 读取自己整理好的CBS文件(录入系统的)
subset_table = pd.read_excel('Data.xlsx',sheet_name='CBS')
# 将两个文件的的数据来核对
for index, row in subset_table.iterrows():
# 获取分表中的两列内容
column1_match = row['GLID Item Number']
column2_match = row['Value']
# 在第一个excel中查找匹配行
matched_rows = total_table.loc[(total_table['GLID Item Number'] == column1_match) & (total_table['Value'] == column2_match)]
# 填充合同号
total_table.loc[matched_rows.index, 'Base Item'] = row['Base Item']
# 保存填充了自己录入系统的base item与系统导出的是否一致
total_table.to_excel('CBS_12.xlsx', index=False)
[/code]
报错的提示,还请帮忙看看
|