首页 > 解决方案 > 为什么我的 python 视觉效果在 Power BI 服务中显示比在 Power BI 桌面中慢?

问题描述

我在 Power BI 中制作了一个 python 视觉对象。代码如下所示。它在 Power BI 桌面上运行得非常快,视觉效果会在 1-2 秒内弹出。但是,当我将其发布到 Power BI 服务时,需要 10 秒才能显示此 python 视觉对象。为什么是这样?

dates_filtered = dataset.delivery_begin.unique()[-3:]
dataset_plot = dataset[dataset.delivery_begin.isin(dates_filtered)]
fig, ax = matplotlib.pyplot.subplots()
if len(dates_filtered) == 3:
    colors = {
    dates_filtered[0] : "#92bbea" ,
    dates_filtered[1] : "#ea9d9a",
    dates_filtered[2] : "#85ceb3"}
elif len(dates_filtered) == 2: 
    colors = {
    dates_filtered[0] : "#ea9d9a",
    dates_filtered[1] : "#85ceb3"}
else:
    colors = {dates_filtered[0] :  "#85ceb3"}   

grouped = dataset_plot.groupby('delivery_begin')
for key, group in grouped:
    group.plot(ax=ax, kind='line', x = "ep_based_cumsum_bins", y = "adjusted_energy_price", label=key, c= colors[key], legend=False, linewidth = 4)
# grouped.apply(lambda x: x.plot(ax=ax, kind='line', x = "ep_based_cumsum_bins", y = "adjusted_energy_price", label=x.name, c= colors[x.name], legend=False, linewidth = 4))
for item in [fig, ax]:
    item.patch.set_visible(False)
ax.axis('off') 
# ax.legend(dataset_plot.delivery_begin.unique(), loc = 'upper left')
legend = matplotlib.pyplot.legend(fontsize=22, loc = 'upper left', frameon = False)
matplotlib.pyplot.setp(legend.get_texts(), color = 'none')
# ax.legend(loc='upper left', fancybox=True, framealpha=0)
matplotlib.pyplot.show()

标签: pythonpowerbi

解决方案


推荐阅读