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()

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM