【发布时间】:2018-06-05 01:49:01
【问题描述】:
我编写了以下代码来使用plotly 库生成几个图表:
#Read the excel file from local spreadsheet
df = pd.read_excel(r'C:\Users\llopez\Documents\Temp\Python finished goods.xlsx', sheet_name='Sheet1')
#Create a dictionary of tuples by year
dict_of_fgs = dict(tuple(df.groupby('Year')))
#Loop through the elements of the dictionary of finished goods and plots them grouping FG, type and calculating the sum of quantities. Stacking by type
for k in dict_of_fgs:
df_grouped = dict_of_fgs[k].groupby(['Finished_Good','Type'],sort=False)['Qty'].sum().unstack('Type').iplot(kind='bar',barmode='stack', title='FG Chart')
它产生以下图表:
这些图表正是我所需要的,所以现在我正在寻找一种方法来生成基于网络的报告并与用户共享。
我查看了以下教程,但我似乎无法调整我的代码,因为我的代码循环通过字典并为每个键(年份)生成一个图。
如何根据我创建的图表生成基于网络的报告?
提前感谢所有主题专家就如何实现这一目标提出了所有伟大的想法。感谢您的帮助。
【问题讨论】:
-
不知道这是否有帮助,但我几周前遇到了这个问题。 highcharts
标签: python django pandas plotly stacked-chart