How to use the holidays.DE function in holidays

To help you get started, we’ve selected a few holidays examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dr-prodigy / python-holidays / tests.py View on Github external
def setUp(self):
        self.holidays = holidays.DE()
        self.prov_hols = dict((prov, holidays.DE(prov=prov))
                              for prov in holidays.DE.PROVINCES)
github dr-prodigy / python-holidays / tests.py View on Github external
def setUp(self):
        self.holidays = holidays.DE()
        self.prov_hols = dict((prov, holidays.DE(prov=prov))
                              for prov in holidays.DE.PROVINCES)
github dr-prodigy / python-holidays / tests.py View on Github external
def test_no_data_before_1990(self):
        de_1989 = sum(holidays.DE(years=[1989], prov=p)
                      for p in holidays.DE.PROVINCES)
        self.assertTrue(len(de_1989) == 0)
github dr-prodigy / python-holidays / tests.py View on Github external
def test_all_holidays_present(self):
        de_2015 = sum(holidays.DE(years=[2015], prov=p)
                      for p in holidays.DE.PROVINCES)
        in_2015 = sum((de_2015.get_list(key) for key in de_2015), [])
        all = ["Neujahr",
               "Heilige Drei Könige",
               "Karfreitag",
               "Ostern",
               "Ostermontag",
               "Maifeiertag",
               "Christi Himmelfahrt",
               "Pfingsten",
               "Pfingstmontag",
               "Fronleichnam",
               "Mariä Himmelfahrt",
               "Tag der Deutschen Einheit",
               "Reformationstag",
               "Allerheiligen",
github h2oai / driverlessai-recipes / transformers / augmentation / germany_landers_holidays.py View on Github external
# General first
        ge_holidays = holidays.DE()
        for year in list(years):
            ge_holidays._populate(year)
        ge_holidays.observed = False
        hdays = [date for date, name in sorted(ge_holidays.items())]
        holidays_df = pd.DataFrame(hdays, columns=[self.time_column], dtype='datetime64[ns]')
        holidays_df['year'] = holidays_df[self.time_column].dt.year
        holidays_df['doy'] = holidays_df[self.time_column].dt.dayofyear
        holidays_df.sort_values(by=['year', 'doy']).drop_duplicates(subset=['year'], keep='first').reset_index(drop=True)
        holidays_df.drop(self.time_column, axis=1, inplace=True)
        self.memos['country'] = holidays_df

        # Now do province in the same manner
        for prov in ['BW', 'BY', 'BE', 'BB', 'HB', 'HH', 'HE', 'MV', 'NI', 'NW', 'RP', 'SL', 'SN', 'ST', 'SH', 'TH']:
            ge_holidays = holidays.DE(prov=prov)
            for year in list(years):
                ge_holidays._populate(year)
            ge_holidays.observed = False
            hdays = [date for date, name in sorted(ge_holidays.items())]
            holidays_df = pd.DataFrame(hdays, columns=[self.time_column], dtype='datetime64[ns]')
            holidays_df['year'] = holidays_df[self.time_column].dt.year
            holidays_df['doy'] = holidays_df[self.time_column].dt.dayofyear
            holidays_df.sort_values(by=['year', 'doy']).drop_duplicates(subset=['year'], keep='first').reset_index(
                drop=True)
            holidays_df.drop(self.time_column, axis=1, inplace=True)
            self.memos[prov] = holidays_df
github h2oai / driverlessai-recipes / transformers / augmentation / germany_landers_holidays.py View on Github external
mn_year = X[self.time_column].dt.year.min()
        mx_year = X[self.time_column].dt.year.max()
        if np.isnan(mn_year) or np.isnan(mx_year):
            years = []
        else:
            # Start at min year and end at 2*max_year - min_year + 1
            # If min year is 2016, max year 2018
            # then we keep dates until 2021
            # As a reminder np.arange(1, 3) returns [1, 2]
            years = np.arange(int(mn_year), int(mx_year + mx_year - mn_year + 2))

        # Germany general and province holidays
        self.memos = {}

        # General first
        ge_holidays = holidays.DE()
        for year in list(years):
            ge_holidays._populate(year)
        ge_holidays.observed = False
        hdays = [date for date, name in sorted(ge_holidays.items())]
        holidays_df = pd.DataFrame(hdays, columns=[self.time_column], dtype='datetime64[ns]')
        holidays_df['year'] = holidays_df[self.time_column].dt.year
        holidays_df['doy'] = holidays_df[self.time_column].dt.dayofyear
        holidays_df.sort_values(by=['year', 'doy']).drop_duplicates(subset=['year'], keep='first').reset_index(drop=True)
        holidays_df.drop(self.time_column, axis=1, inplace=True)
        self.memos['country'] = holidays_df

        # Now do province in the same manner
        for prov in ['BW', 'BY', 'BE', 'BB', 'HB', 'HH', 'HE', 'MV', 'NI', 'NW', 'RP', 'SL', 'SN', 'ST', 'SH', 'TH']:
            ge_holidays = holidays.DE(prov=prov)
            for year in list(years):
                ge_holidays._populate(year)