Python with pd.ExcelWriter(‘a.xls‘) as writer: 新建excel文件,保存2个sheet

import pandas as pd

new1 = pd.DataFrame({
    
    0:['a','b','c'], 1:['q1','q2','q3'], 2:['t3','t2','t1']})
new2 = pd.DataFrame({
    
    0:['aq1','bq2','cq3'], 1:['la1','la2','la3']})

with pd.ExcelWriter('a.xls') as writer:
    new1.to_excel(writer, 'sheet1')
    new2.to_excel(writer, 'sheet2')

猜你喜欢

转载自blog.csdn.net/qq_27866857/article/details/119795625
今日推荐