使用XlsxWriter将大 pandas 图表插入Excel文件 [英] Insert pandas chart into an Excel file using XlsxWriter
问题描述
我使用python 3.4,pandas 0.14.1和XlsxWriter 0.5.6. 我使用下面的代码使用熊猫创建了一个名为"graph"的图形
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.
现在,如何使用XlsxWriter将图形插入Excel文件?
Now, how do I insert that graph into an Excel file using XlsxWriter?
我尝试了XlsxWriter方法
I tried the XlsxWriter method
workbook.add_chart()
但这会在Excel中创建图形,而不是我想要的图形.
but this creates a graph in Excel, not what I want.
谢谢
推荐答案
如果您想使用XlsxWriter将Pandas数据导出为Excel中的图表,请查看以下方法(我写的):使用Pandas和XlsxWriter创建Excel图表.
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.
如果另一方面,您想要由Pandas生成的matplotlib样式表,然后将其导出为图像,并使用XlsxWriter
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.
另请参见使用Python熊猫和XlsxWriter .
这篇关于使用XlsxWriter将大 pandas 图表插入Excel文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!