Useful classes to generate date features and add them to TimeGPT.


source

CountryHolidays

 CountryHolidays (countries:list[str])

Given a list of countries, returns a dataframe with holidays for each country.

c_holidays = CountryHolidays(countries=['US', 'MX'])
periods = 365 * 5
dates = pd.date_range(end='2023-09-01', periods=periods)
holidays_df = c_holidays(dates)
holidays_df.head()

source

SpecialDates

 SpecialDates (special_dates:dict[str,list[str]])

Given a dictionary of categories and dates, returns a dataframe with the special dates.

special_dates = SpecialDates(
    special_dates={
        'Important Dates': ['2021-02-26', '2020-02-26'],
        'Very Important Dates': ['2021-01-26', '2020-01-26', '2019-01-26']
    }
)
periods = 365 * 5
dates = pd.date_range(end='2023-09-01', periods=periods)
holidays_df = special_dates(dates)
holidays_df.head()