66256/building-time-series-model-getting-error-involving-datetime

CODE SNIPPETS:

...

#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()

ERROR:

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

Hey, @Sharonda,

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

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 model.py file.

Thank You!!

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?

#code

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)) ax.fill_between(pred_ci.index, pred_ci.iloc[:, 0], pred_ci.iloc[:, 1], color='k', alpha=.2) ax.set_xlabel('Date') ax.set_ylabel('Close') plt.legend() plt.show()

ERROR

Hello Sanket Dayama,

You have two options:

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.

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

train1_reindex = train1.reindex(pd.DatetimeIndex(start=train1.date[0], end=train1.date[-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!!

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

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

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

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

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

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

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

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

Hii, In Python2, dictionary.iteritems() is more efficient than ...READ MORE

Hello, I had numpy installed on the same ...READ MORE

OR

Already have an account? Sign in.