简体   繁体   English

如何将 Pandas dataframe 写入现有的 Excel 表?

[英]How to write a Pandas dataframe to an existing Excel table?

I would like to write an exisiting Pandas DF to an existing Excel table (or any named range in an Excel sheet for that matter) – essentially replacing the current Excel table with the dataframe. I would like to write an exisiting Pandas DF to an existing Excel table (or any named range in an Excel sheet for that matter) – essentially replacing the current Excel table with the dataframe. How would you approach this?你会如何处理这个问题?

You can do that with mode='a'你可以用mode='a'做到这一点

From the official docs: 来自官方文档:

with pd.ExcelWriter('output.xlsx',mode='a') as writer:  
    df.to_excel(writer,
                sheet_name='Sheet_name_3',
                startrow=0, 
                startcol=0)

To specify a specific position set startrow , and startcol accordingly.要指定特定的 position 设置startrow ,并startcol

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

相关问题 将 Pandas DataFrame 写入现有的 MySQL 数据库表 - Write Pandas DataFrame into a existing MySQL Database Table 将熊猫数据框附加到现有的Excel表中 - Append a pandas dataframe to an existing excel table 如何将 Pandas Dataframe 写入现有的 Django model - How to write a Pandas Dataframe to existing Django model 如何在现有 Excel 工作表下方写入数据框而不会丢失数据透视表中的 excel 切片器? - How to write dataframe below an existing Excel sheet without losing slicer of excel in pivot table sheet? 如何在不删除标题和标题的情况下将 Pandas DataFrame 写入现有的 Excel 模板? - How can I write pandas DataFrame to existing Excel template without deleting titles and headers? 将 Pandas dataframe 数据写入 existing.docx 文档表的快速方法 - A fast way to write Pandas dataframe data into existing .docx document table 如何将熊猫数据框合并到现有的reportlab表中? - How to merge pandas dataframe into existing reportlab table? 如何将 pandas 表写入 Excel 表? - How to write a pandas table into an Excel table? 如何以Excel形式附加到表格Pandas Dataframe - How to append to a table in Excel form Pandas Dataframe 将 pandas dataframe 逐列写入现有的 excel 模板跳过 ZBF57C906FA7D25856D07372E 中的表格列 - Write pandas dataframe column by column to existing excel template skipping excel sheet columns that have formulas in it
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM