我试图在运行Tabpy服务器的情况下在Tableau中将以下python代码作为计算变量运行:
SCRIPT_REAL(
"
import statsmodels.api as sm
x = _arg1
y = _arg2
lowess = sm.nonparametric.lowess(y, x, frac = .75)
thing = lowess.T[1].tolist()
result=[round(i,10) for i in thing]
return result
",
ATTR([Lowess Date]), ATTR([Scatter Data]))
基于服务器控制台,python代码似乎正在运行。
INFO:__main__:{"INFO": "function to evaluate=def _user_script(tabpy, _arg2, _arg1):\n \n import statsmodels.api as sm\n x = _arg1\n y = _arg2\n \n lowess = sm.nonparametric.lowess(y, x, frac = .75)\n thing = lowess.T[1].tolist()\n result=[round(i,10) for i in thing]\n \n return result\n"}
INFO:tornado.access:200 POST /evaluate (127.0.0.1) 3.00ms
但是,我不断收到以下错误代码,这对我来说似乎没有任何意义。
Unexpected number of results returned by SCRIPT function. Function expected 1 values; 0 values were returned.
有什么想法吗?
注意:数据输入可以是您想要的任何随机散点图数据。在这种情况下,我使用数字日期值(即43302)和y随机值。