pandas操作excel表
import pandas as pd
#pandas读取excel表数据(3个excel) pd.set_option('display.max_columns',None) pd.set_option('display.max_rows',None) f1 = pd.read_excel(io=r'C:\Users\wzc\Desktop\test2-1.xlsx') f2 = pd.read_excel(io=r'C:\Users\wzc\Desktop\test2-2.xlsx') f3 = pd.read_excel(io=r'C:\Users\wzc\Desktop\test2-3.xlsx')
#将3个excel表需要操作的数据提取到一个列表中 f = [f3,f1.iloc[:,1:4],f2.iloc[:,1:5]] # print(f)
#创建一个test123.xlsx表 write = pd.ExcelWriter(r'C:\Users\wzc\Desktop\test123.xlsx')
# 合并行axis=1,(axis=0,默认 则为合并列)
pd.concat(f,sort=True,axis=1).to_excel(write,'Sheet1',index=False) write.save()