[ENH] Implement ForecastingHorizon.to_indexer
method for non-integer forecasting horizons
#2376
Labels
enhancement
Adding new functionality
Is your feature request related to a problem? Please describe.
In #2333 I have generalized
ForecastingHorizon
to accept non-integer forecasting horizons, e.g.pd.Timedelta
. The only method which is not adjusted isForecastingHorizon.to_indexer
. In the referenced PR it raisesNotImplementedError
instead. The main reason I left it at that is that personally I do not understand the meaning of this method for non-integer indices. Let's say we have a time series with the following date index:[Jan 1, Jan 2, Jan 2, Jan 5]
. The integer index here is[0, 1, 2, 3]
. But if I start thinking in relative time-based terms, sayfh = 1 day
, and acutoff = Jan 2
, then indexing into the this time series is nothing but defining a time threshold and simply filtering out either values before or after this threshold, sayJan 3
, ory[y.index < cutoff + fh]
. In such arithmetic integer index is just not very helpful.Describe the solution you'd like
If I saw the solution, I would have implemented it straight away. Unfortunately, I do not see one without digging deep into how this method is used in other places of the library.
The text was updated successfully, but these errors were encountered: