Insert pandas chart into an Excel file using XlsxWriter

南楼画角 提交于 2019-12-10 03:57:53

问题


I use python 3.4, pandas 0.14.1 and XlsxWriter 0.5.6. I create a graph called 'graph' using pandas with the following code

 graph=data_iter['_DiffPrice'].hist() 

, which produces a beautiful histogram.

Now, how do I insert that graph into an Excel file using XlsxWriter?

I tried the XlsxWriter method

workbook.add_chart()

but this creates a graph in Excel, not what I want.

Thanks


回答1:


If you would like to export Pandas data as charts in Excel using XlsxWriter then have a look at the following how-to (that I wrote): Using Pandas and XlsxWriter to create Excel charts.

If on the other hand you want the matplotlib style charts generated by Pandas then export them as images and insert them into a worksheet using the XlsxWriter insert_image() method.

See also Working with Python Pandas and XlsxWriter.



来源:https://stackoverflow.com/questions/24907210/insert-pandas-chart-into-an-excel-file-using-xlsxwriter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!