Power BI Python视觉效果

时间:2020-04-22 14:40:35

标签: python powerbi

我正在尝试在power bi中运行python视觉。我正在尝试进行简单的时间序列预测。我正在使用我们组织的power bi数据集,我的简单代码如下:

# dataset = pandas.DataFrame(xxxx, yyyy)
# dataset = dataset.drop_duplicates()

# Paste or type your script code here:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from statsmodels.tsa.arima_model import ARMA
from statsmodels.tsa.statespace.sarimax import SARIMAX
from numpy import cumsum

pvt_table = pd.pivot_table(dataset, values='xxxx', index='yyyy', aggfunc='count')
model=SARIMAX(pvt_table, order=(0,0,1), seasonal_order=(1,1,1,12))
results=model.fit()
residuals=results.resid
mae=np.mean(np.abs(residuals))

forecast=results.get_forecast(steps=12).predicted_mean 
#mean_forecast=np.cumsum(forecast) + pvt_table.iloc[-1,0]

#plt.plot(pvt_table, label='observed')
plt.plot(forecast, label='forecast', color='green', linestyle='dashed', linewidth=4, marker='o',       markerfacecolor='blue', markersize=12)
plt.legend()
plt.show()

我的问题是,在Power Bi桌面中,我可以使用任何日期过滤器或其他过滤器,我可以进行预测。但是,当我将此报告发布到app.powerbi.com并更改过滤器时,出现以下错误: “脚本运行时错误

%freq,ValueWarning)

[S-7efd1f61-7cec-4494-83a6-7b28fdf10b83]追踪(最近一次通话结束):

文件

中的文件“ C:\ Script \ 0.py”,第37行
results=model.fit()

适合的文件“ C:\ Python \ lib \ site-packages \ statsmodels \ tsa \ statespace \ mlemodel.py”,第445行

start_params = self.start_params

文件“ C:\ Python \ lib \ site-packages \ statsmodels \ tsa \ statespace \ sarimax.py”,行969,在start_params中

self.k_seasonal_ma, self.polynomial_seasonal_ma

文件“ C:\ Python \ lib \ site-packages \ statsmodels \ tsa \ statespace \ sarimax.py”,行845,在_conditional_sum_squares中

X = lagmat(endog, k, trim='both')

lagmat中的文件“ C:\ Python \ lib \ site-packages \ statsmodels \ tsa \ tsatools.py”,第408行

raise ValueError("maxlag should be < nobs")

ValueError:maxlag应该为

我找不到任何解决方案。我已经在本地pycharm中检查了我的代码,它可以正常工作。 谢谢。

0 个答案:

没有答案