简体   繁体   中英

Export 3 SQL Query results to 3 sheets in an excel sheet through python pandas

如何使代码更智能地工作并将 3 个不同查询的结果导出到单个 .xls 文件的 3 个不同工作表?

save your queries results in individual 3 dataframes. and then it looks like this- pandas is alias here as pd.

writer = pd.ExcelWriter('filename.xlsx', engine='xlsxwriter')
    yours1stdataframe.to_excel(writer, sheet_name='whatverulike')
     yours2nddataframe.to_excel(writer, sheet_name='whatverulike')
     yours3rddataframe.to_excel(writer, sheet_name='whatverulike')

    writer.save()

This should solve your problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM