2016-07-27 101 views
-3

我需要添加幾個df到一個excel,我希望它們看起來像 enter image description here。 是pandas中的任何函數。那可以做到嗎?熊貓:添加幾個數據幀到一個Excel文件

+0

看看[這個](http://stackoverflow.com/questions/34945456/is-it-possible-to-insert-a-worksheet-into-an-existing-workbook-using-python)和還有[this](http://stackoverflow.com/questions/35604888/how-to-persist-excel-references-in-formulas-across-worksheets-where-the-workshee) – toasteez

+0

和[this](http: /stackoverflow.com/questions/37320355/using-named-ranges-in-excel-with-a-selection-of-cells)我不得不創建一個帶有命名範圍的模板,然後添加一些數據來顯示。 – toasteez

回答

1

有關佈局,請參閱to_excel文檔。 請注意,您必須將它傳遞給pd.ExcelWriter對象而不是路徑字符串,然後調用它的save方法以便能夠將多個數據框保存到同一個excel文件(相同或不同的工作表)。

對於設計本身,這將需要一些擺弄openpyxl

您可以試試我編寫的一個庫,名爲StyleFrame(記錄在githubreadthedocs),並查看它是否滿足您的需求。