pandas 数据导出为csv Excel格式

你的名字 2023-06-06 04:53 64阅读 0赞
  1. import pandas as pd
  2. #string to show exporting data to csv
  3. ''' df.to_csv( filepath_or_buffer:path to story to sep = ',':column separator columns:list needed to export header = True:Specify column names of new datas,also support list index = True :if or not export index mode = 'w':python's write mode , modes: r r+ w w+ a a+ encoding = 'utf-8'encoding format of data ) '''
  4. #code to show exporting data to excel
  5. df1 = pd.read_csv('123.csv',encoding = 'utf-8')
  6. df2 = pd.read_csv('123.csv',encoding = 'utf-8')
  7. writer = pd.ExcelWriter('output.xlsx')
  8. df1.to_excel(writer,'Sheet1')
  9. df2.to_excel(writer,'Sheet2')
  10. writer.save()

发表评论

表情:
评论列表 (有 0 条评论,64人围观)

还没有评论,来说两句吧...

相关阅读

    相关 js导出excelcsv

    导出页面表格里的数据为excel,IE浏览器要用到插件ActiveXObject 非IE浏览器下可以通过设置a标签的形式,将要导出的数据追加到a标签的href属性上,从而实现