简体   繁体   English

通过python pandas将3个SQL查询结果导出到excel表中的3个表中

[英]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.将您的查询结果保存在单独的 3 个数据框中。 and then it looks like this- pandas is alias here as pd.然后它看起来像这样——pandas 在这里的别名是 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.这应该可以解决您的问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将 dfs 导出到带有多个工作表和不同工作表名称的 excel 熊猫 - How to export dfs to excel with multiple sheets and different sheet names pandas 使用pandas在excel中创建多个工作表以循环工作表名称 - Create multiple sheets in excel using pandas to loop through sheet names 如何通过python中的pandas导出单个csv文件的多个excel表 - How to export to multiple excel sheet of a single csv file through pandas in python 将查询结果附加到python中Excel中的不同工作表 - Append Query Results to Different Sheets in Excel in python Python Pandas - 循环浏览 Excel 文件的文件夹,将每个 ZC1D81AF583580.x 文件的数据导出到它们自己的文件“DED8FDCZ”中 - Python Pandas - loop through folder of Excel files, export data from each Excel file's sheet into their own .xlsx file oracle sql query and export excel and send email not shown persian and shown as question mark pandas python - oracle sql query and export excel and send email not shown persian and shown as question mark pandas python 如何在python中使用Pandas遍历Excel工作表的日期标头? - How to iterate through date header of excel sheet using pandas in python? 如何通过工作表名称(Pandas)解析Excel工作表 - How to parse excel sheets by sheet name (Pandas) 将 Python 列表导出到 Excel 工作表 - Export Python List to Excel Sheet 将熊猫数据框导出到Excel工作表中的不同行 - Export pandas dataframes to different rows in Excel sheet
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM