Nixtla / utilsforecast

https://nixtlaverse.nixtla.io/utilsforecast
Apache License 2.0
40 stars 6 forks source link

[FEAT] support for pandas frequencies in generate_series #33

Closed AzulGarza closed 10 months ago

AzulGarza commented 10 months ago

I'm currently testing code against dataframes with various pandas-supported frequencies and using generate_series to create these dataframes. However, I noticed that only daily and monthly frequencies are supported:

image

The limitation appears to be related to how season is defined for each frequency, which is necessary for simulating seasonal behavior as seen in this snippet from data.py:

https://github.com/Nixtla/utilsforecast/blob/2812ef011905e202fa801b6a28f7b43f892e2d78/utilsforecast/data.py#L90

For frequencies not accounted for in seasonalities, I suggest we could raise a warning and then populate the y variable with a random distribution. This approach could be particularly useful when the model's performance isn't being evaluated, and we're more interested in the structure of the dataframe for a specific frequency.

AzulGarza commented 10 months ago

A workaround is just:

freq = 'W-THU'

df = generate_series(10)
df['ds'] = df.groupby('unique_id')['ds'].transform(
    lambda x: pd.date_range(periods=len(x), freq=freq, end='2023-01-01')
)