pandas进行表格的合并
#!/bin/python
import pandas as pd
import openpyxl
excel_file = pd.read_excel('input1.xlsx', sheet_name=['sheet1', 'sheet2'])
table1 = excel_file['sheet1']
table2 = excel_file['sheet2']
#header_order = ['XX1', 'XX2','相同的列名XX']
merged_table = pd.merge(table1 , table2 , on='相同的列名XX')#.reindex(columns=header_order)
excel_writer = pd.ExcelWriter('merged_output.xlsx', engine='openpyxl')
merged_table.to_excel(excel_writer, sheet_name='merge_XX', index=False)
excel_writer._save()
网友评论