Building Time Series Model - Getting error involving datetime

0 votes



#get predictions starting from 2016-01-01 and calculate confidence intervals
        pred = output.get_prediction(start=pd.to_datetime('2017-09-14'), dynamic=False)
        pred_conf = pred.conf_int()


TypeError: int() argument must be a string, a bytes-like object or a number, not 'Timestamp'
Apr 8, 2020 in Python by Sharonda
• 150 points

Hey, @Sharonda,

Could you please how did you try to run your code? And along with can you please also post your

1 answer to this question.

0 votes
Best answer

Hey sharonda,

Use a python datetime or string 

results.get_prediction(start='2020-04-08', axis=0)
# or
import datetime as dt
results.get_prediction(start=dt.datetime(2020, 4, 8), axis=0)

Try this once or post your file.

Thank You!!

answered Apr 8, 2020 by Niroj
• 82,760 points

selected Apr 9, 2020 by Sharonda

Thank you, Niroj the following statement cleared the error:


results.get_prediction(start='2020-04-08', axis=0)

Hello I am experiencing a similar error and tried the same thing but did not work. Can you please guide me on this?


pred = results.get_prediction(start=pd.to_datetime('2019-09-25'), dynamic=False, axis = 0)
pred_ci = pred.conf_int()
ax = y[:].plot(label='observed')
pred.predicted_mean.plot(ax=ax, label='One-step ahead Forecast', alpha=.7, figsize=(14, 4))
                pred_ci.iloc[:, 0],
                pred_ci.iloc[:, 1], color='k', alpha=.2)


TypeError: int() argument must be a string, a bytes-like object or a number, not 'Timestamp'

Hello Sanket Dayama,

You have two options:

  1. You can call results.predict using integers for start and end (e.g. results.predict(start=results.nobs, end=results.nobs + 10)) and then attach whatever dates you like to the resulting forecasts.

  2. You can reindex your data to have a date series with daily frequency. For example:

train1_reindex = train1.reindex(pd.DatetimeIndex([0],[-1], freq='D'))

This will mean your new time series will have NaNs in it, but that's not a problem for SARIMAX. In fact, it should give you better results, since simply removing missing observations is not the right way to deal with missing observations in models like ARIMA where today's value depends on yesterday's value.

Hope this helps!!

Related Questions In Python

0 votes
1 answer

How does time series analysis with statsmodels work?

I'd really like to see a data ...READ MORE

answered Sep 4, 2018 in Python by Priyaj
• 58,120 points
0 votes
1 answer

Getting this error Error sqlite3.InterfaceError: Error binding parameter 0 - probably unsupported type

Found out that the problem was that ...READ MORE

answered Oct 1, 2018 in Python by Priyaj
• 58,120 points
0 votes
1 answer

Why am I getting a error when I am printing two different data types in python?

different data type is being used. that ...READ MORE

answered Mar 6, 2019 in Python by Mohammad
• 3,230 points
0 votes
1 answer

Python error "'Series' object is not callable "

Try this: df['ln_returns'] = np.log(df['Close_mid']/df['Close_mid']) df['Close_mid'](1)) doesn't seem to ...READ MORE

answered Jul 22, 2019 in Python by Greg
0 votes
1 answer

R lag irregular time series data

You could try using: library(dplyr) library(zoo) na.locf(ts$value[sapply(ts$time, function(x) min(which(ts$time - ...READ MORE

answered May 11, 2018 in Data Analytics by Sahiti
• 6,380 points
0 votes
1 answer

Different types of seasonality in time series modelling

Seasonality in time series occurs when the ...READ MORE

answered Aug 8, 2018 in Data Analytics by DataKing99
• 8,240 points
+1 vote
1 answer

Building a Time series prediction model on web login timestamp

I had done something similar and ran ...READ MORE

answered Dec 7, 2018 in Data Analytics by Upasana
• 8,620 points
0 votes
2 answers

What is difference between Distributed search head and Search head cluster?

 A distributed environment describes the separation of ...READ MORE

answered Dec 3, 2018 in Data Analytics by Ali
• 11,320 points
0 votes
1 answer

Error:django-debug-toolbar breaking on admin while getting sql stats

Hello @kartik, You just need to be able ...READ MORE

answered Jun 12, 2020 in Python by Niroj
• 82,760 points
+1 vote
1 answer

Error:Getting Site Matching Query Does Not Exist Error after creating django admin

Hello @kartik, The Site object for your Django project is ...READ MORE

answered Jun 22, 2020 in Python by Niroj
• 82,760 points