TypeError: only integer scalar arrays can be converted to a scalar index

How do I solve the error :TypeError: only integer scalar arrays can be converted to a scalar index

#creating the train and validation set (80% - 20%)
train = data[:int(0.8*(len(data)))]
valid = data[int(0.8*(len(data))):]

#fit the model
from statsmodels.tsa.vector_ar.var_model import VAR

model = VAR(endog=train)
model_fit = model.fit()
#model_fit.y

make prediction on validation

prediction = model_fit.forecast(model_fit.y, steps=len(valid))

Always put code as text, not image. Python can’t load image to run code. And mouse can’t select code on image to copy it to Python.

Always put full error message - starting at work Traceback. it show other interesting information - like which line makes problem.

And learn how to use editor in this page. It has special button to format and highlight selected code.

© Copyright 2013-2021 Analytics Vidhya