I have dataset with dates and random values. The following code is generating the dataset.
def random_dates(start, end, n=10):
start_u = start.value//10**9
end_u = end.value//10**9
return pd.DatetimeIndex((10**9*np.random.randint(start_u, end_u, n)))
start = pd.to_datetime('2017-01-01')
end = pd.to_datetime('2018-01-12')
days = random_dates(start, end)
np.random.seed(seed=1111)
data = np.random.randint(1, high=100, size=len(days))
df = pd.DataFrame({'Date': days, 'values': data})
df = df.set_index('Date')
print(df)
I am trying to implement ARIMA timeseries model on the dataset to predict for November, 2018 to December, 2018. From the dataset image it can be seen that I put zeros for the dates where I need to predict the values.
I code below is to do prediction. However, I am getting error at line:2 start of get_prediction is not able to get assigned to the date value of dataframe that I want. TypeError: int() argument must be a string, a bytes-like object or a number, not 'Timestamp'
start = pd.to_datetime("2018-01-10")
pred = results.get_prediction(start, dynamic=False)
pred_ci = pred.conf_int()
ax = tc.plot(label='observed')
pred.predicted_mean.plot(ax=ax, label='One-step ahead Forecast', alpha=.7, figsize=(14, 7))
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('TC')
plt.legend()
plt.show()
I tried to change the date-index to string but it is giving the same error. Kindly tell me where I went wrong. Thanks