I am writing a time serie prediction algorithm where I need to iterate over multiple times series within the same df. It looks something like:
def predict(self, ts, cat=None, encoding="utf-8", num_samples=100, quantiles=["0.1", "0.75", "0.9"]):
prediction_times = [x.index[-1]+1 for x in ts]
req = self.__encode_request(ts, cat, encoding, num_samples, quantiles)
res = super(DeepARPredictor, self).predict(req)
return self.__decode_response(res, prediction_times, encoding)
when calling the function later on in my code, the line
prediction_times = [x.index[-1]+1 for x in ts]
#index is a DateTimeIndex format
throws the following error:
TypeError: Addition/subtraction of integers and integer-arrays with Timestamp is no longer supported. Instead of adding/subtracting `n`, use `n * obj.freq`
ts looks something like that:
Name: 100000ST, Length: 1989, dtype: int64, 2015-01-05 0
2015-01-06 0
2015-01-07 0
2015-01-08 0
2015-01-09 0
..
2020-06-11 0
2020-06-12 0
2020-06-13 0
2020-06-14 0
2020-06-15 0
Name: 100005ST, Length: 1989, dtype: int64, 2015-01-05 5
2015-01-06 0
2015-01-07 0
2015-01-08 40
2015-01-09 0
..
2020-06-11 75
2020-06-12 21
2020-06-13 0
2020-06-14 0
2020-06-15 0
I am not able to find a way to change this line to achieve the same result without the error. Any suggestion?
UPDATE: trying out prediction_times = [x.index.shift(freq=1) for x in ts]
yields the same error