【利用Python进行数据分析——经验篇4】将多张DataFrame表写入到同一个Excel的不同sheet中

# 创建一个输出文件

writer = pd.ExcelWriter('out.xlsx')



data = pd.read_table('table_All_pivot.csv',sep=',')
data.to_excel(writer,'table_All_pivot',index=False)


sf_All = pd.read_table('sf_All.csv', sep=',' )
sf_All.to_excel(writer,'sf_All',columns=sf_All.columns[2:],index=False)


table_All_f = pd.read_csv('table_All.csv',sep=',')
table_All_f.to_excel(writer,'table_All_f',columns=table_All_f.columns[1:],index=False)


sfweibo_All_f = pd.read_csv('sfweibo_All_f.csv')
sfweibo_All_f.to_excel(writer,'sfweibo_All_f',columns=sfweibo_All_f.columns[1:],index=False)


base = pd.read_excel('test1.xlsx','Sheet2')
base.to_excel(writer,'base',index=False)


writer.save()


你可能感兴趣的:(Python实用操作基础)