Closed AzulGarza closed 9 months ago
A workaround:
When using start='global'
, we don't need the correct dates while filling the gaps. We can transform the dates to daily frequency, fill the gaps, and then retransform the dates to the required frequency:
import pandas as pd
from utilsforecast.data import generate_series
from utilsforecast.preprocessing import fill_gaps
freq = 'Q-DEC'
series = generate_series(
10,
freq=freq,
equal_ends=True,
min_length=10,
max_length=30,
)
dates = sorted(series['ds'].unique())
dates_replacer = dict(zip(dates, pd.date_range(end='2021-01-01', periods=len(dates))))
series_dates_replaced = series.replace(dates_replacer)
series_dates_replaced = fill_gaps(series_dates_replaced, freq='D', start='global')
series_filled = series_dates_replaced.replace({v: k for k, v in dates_replacer.items()})
assert series['y'].sum() == series_filled['y'].sum()
Would freq='3M'
work here?
It works perfectly, thank you @jmoralez🎉
Passing
Q
-related frequencies tofill_gaps
throws the following error: