Reputation: 1
I am using the following code for arima to predict values of output for the given date value from 2018-10-17
to 2018-10-22
. But I get the error as
ERROR: "int() argument must be a string, a bytes-like object or a number, not 'Timestamp'".
model = ARIMA(df, order=(5,1,0))
model = model.fit(disp=0)
pred = model.get_prediction(start=pd.to_datetime('2018-10-17'),
end=pd.to_datetime('2018-10-22'),
dynamic=True)
Doesn't predict()
accept datetime
objects? It says it does in the documentation.
Upvotes: 0
Views: 2045
Reputation: 880887
Assuming you are using statsmodels.tsa.statespace.sarimax.SARIMAXResults.get_prediction
, notice that start
and end
expect an int
, str
, or datetime. Per the docs, the str can be a date string, so you could use
pred = model.get_prediction(start='2018-10-17',
end='2018-10-22',
dynamic=True)
Pandas Timestamps are not the same as Python datetime.datetime objects.
If you wish to use a datetime, use the Timestamp.to_pydatetime()
method to convert Pandas Timestamps to Python datetime.datetime objects:
In [181]: pd.to_datetime('2018-10-17')
Out[181]: Timestamp('2018-10-17 00:00:00')
In [180]: pd.to_datetime('2018-10-17').to_pydatetime()
Out[180]: datetime.datetime(2018, 10, 17, 0, 0)
or simply create the datetime.datetime object directly:
In [184]: import datetime as DT
In [185]: DT.datetime(2018,10,17)
Out[185]: datetime.datetime(2018, 10, 17, 0, 0)
pred = model.get_prediction(start=DT.datetime(2018, 10, 17),
end=DT.datetime(2018, 10, 22),
dynamic=True)
Upvotes: 1