hey everyone, i am trying to get this script to work, but i'm not very familiar with Python.. can someone please help me figure out how to print the output of this function to alteryx?
ive attached a workflow
from ayx import Package
from ayx import Alteryx
from statsmodels.tsa.statespace.sarimax import SARIMAX
df = Alteryx.read("#1")
df
x = df['X']
data = df['Y']
# SARIMA example
# contrived dataset
# fit model
model = SARIMAX(data, order=(1, 1, 1), seasonal_order=(0, 0, 0, 0))
model_fit = model.fit(disp=False)
# make prediction
yhat = model_fit.predict(len(data), len(data))
df['a'] = yhat
Alteryx.write(df, 1)
Solved! Go to Solution.
Got it to work. Part of the problem is that the script wasn't generating new rows to project the prediction into.. I couldn't figure out how to create new rows in python, but I used the Alteryx row generator for that part.
from ayx import Package
from ayx import Alteryx
from statsmodels.tsa.statespace.sarimax import SARIMAX
df = Alteryx.read("#1")
df
x = df['X']
y = df['Y']
# SARIMA example
# contrived dataset
# fit model
model = SARIMAX(y, order=(1, 1, 1), seasonal_order=(3, 1, 3, 12))
model_fit = model.fit(disp=False)
# make prediction
yhat = model_fit.predict(0, len(y)+18)
df['Forecast'] = yhat
Alteryx.write(df, 1)