Пример #1
0
    def test_events(self):
        assert holidays.new_years(2013) == (2013, 1, 1)
        assert holidays.martin_luther_king_day(2015) == (2015, 1, 19)

        assert holidays.lincolns_birthday(2015) == (2015, 2, 12)
        assert holidays.valentines_day(2015) == (2015, 2, 14)
        assert holidays.washingtons_birthday(2015) == (2015, 2, 22)
        assert holidays.presidents_day(2015) == (2015, 2, 16)

        assert holidays.pulaski_day(2015) == (2015, 3, 2)
        assert self.h.pulaski_day == (2015, 3, 2)

        assert holidays.may_day(2015) == (2015, 5, 1)

        assert holidays.columbus_day(2015, 'canada') == (2015, 10, 12)

        assert holidays.independence_day(2015) == (2015, 7, 4)
        assert holidays.independence_day(2015, True) == (2015, 7, 3)
Пример #2
0
    def test_events(self):
        assert holidays.new_years(2013) == (2013, 1, 1)
        assert holidays.martin_luther_king_day(2015) == (2015, 1, 19)

        assert holidays.lincolns_birthday(2015) == (2015, 2, 12)
        assert holidays.valentines_day(2015) == (2015, 2, 14)
        assert holidays.washingtons_birthday(2015) == (2015, 2, 22)
        assert holidays.presidents_day(2015) == (2015, 2, 16)

        assert holidays.pulaski_day(2015) == (2015, 3, 2)
        assert self.h.pulaski_day == (2015, 3, 2)

        assert holidays.may_day(2015) == (2015, 5, 1)

        assert holidays.columbus_day(2015, 'canada') == (2015, 10, 12)

        assert holidays.independence_day(2015) == (2015, 7, 4)
        assert holidays.independence_day(2015, True) == (2015, 7, 3)
Пример #3
0
def check_holiday(date):
  holiday_check = 0
  if date.month == 1 and date.day == 1: holiday_check = 1
  if date.month == 1 and date.day == 20: holiday_check = 1
  if date.month == 7 and date.day == 4: holiday_check = 1
  if date.month == 11 and date.day == 11: holiday_check = 1
  if date.month == 12 and date.day == 24: holiday_check = 1
  if date.month == 12 and date.day == 25: holiday_check = 1
  if date.month == 13 and date.day == 31: holiday_check = 1

  for holiday in [holidays.martin_luther_king_day(date.year),
                  holidays.presidents_day(date.year),
                  holidays.memorial_day(date.year),
                  holidays.labor_day(date.year),
                  holidays.columbus_day(date.year),
                  holidays.thanksgiving(date.year)]:
    holiday_check = 1
  return holiday_check
Пример #4
0
def holiday_feature(station_data):
    holiday_data = np.zeros((len(station_data['event_date'])))
    # print dir(holidays)

    for index, event_date in enumerate(station_data['event_date']):
        if event_date.month == 1 and event_date.day == 1: holiday_data[index] = 1
        if event_date.month == 1 and event_date.day == 20: holiday_data[index] = 1
        if event_date.month == 7 and event_date.day == 4: holiday_data[index] = 1
        if event_date.month == 11 and event_date.day == 11: holiday_data[index] = 1
        if event_date.month == 12 and event_date.day == 24: holiday_data[index] = 1
        if event_date.month == 12 and event_date.day == 25: holiday_data[index] = 1
        if event_date.month == 12 and event_date.day == 31: holiday_data[index] = 1
        for holiday in [holidays.martin_luther_king_day(event_date.year),
                        holidays.presidents_day(event_date.year),
                        holidays.memorial_day(event_date.year),
                        holidays.labor_day(event_date.year),
                        holidays.columbus_day(event_date.year),
                        holidays.thanksgiving(event_date.year)]:
            if event_date.month == holiday[1] and event_date.day == holiday[2]:
                holiday_data[index] = 1

    station_data['holidays'] = holiday_data
    return station_data