Пример #1
0
 def judge_local_holiday(self, df):
     country = df['geoNetwork_country']
     date = df['visitId'].apply(lambda x: x.date())
     judge_holiday = \
         np.where(country.isin(
                 ['United States','India','Canada','Germany',
                  'Japan','France','Mexico','Australia',
                  'Spain','Netherlands','Italy','Ireland',
                  'Sweden','Argentina','Colombia','Belgium',
                  'Switzerland','Czechia','Colombia','Belgium',
                  'New Zealand','South Africa','South Africa']),\
         np.where((country=='United States')&
                  (date.isin(holidays.US())),1,
                  np.where((country=='India')&
                           (date.isin(holidays.India())),1,
                           np.where((country=='Canada')&
                                    (date.isin(holidays.CA())),1,
                                    np.where((country=='Germany')&
                                             (date.isin(holidays.DE())),1,\
         np.where((country=='Japan')&
                  (date.isin(holidays.JP())),1,
                  np.where((country=='France')&
                           (date.isin(holidays.FRA())),1,
                           np.where((country=='Mexico')&
                                    (date.isin(holidays.MX())),1,
                                    np.where((country=='Australia')&
                                             (date.isin(holidays.AU())),1,\
         np.where((country=='Spain')&
                  (date.isin(holidays.ES())),1,
                  np.where((country=='Netherlands')&
                           (date.isin(holidays.NL())),1,
                           np.where((country=='Italy')&
                                    (date.isin(holidays.IT())),1,
                                    np.where((country=='Ireland')&
                                             (date.isin(holidays.IE())),1,\
         np.where((country=='Sweden')&
                  (date.isin(holidays.SE())),1,
                  np.where((country=='Argentina')&
                           (date.isin(holidays.AR())),1,
                           np.where((country=='Colombia')&
                                    (date.isin(holidays.CO())),1,
                                    np.where((country=='Belgium')&
                                             (date.isin(holidays.BE())),1,\
         np.where((country=='Switzerland')&
                  (date.isin(holidays.CH())),1,
                  np.where((country=='Czechia')&
                           (date.isin(holidays.CZ())),1,
                           np.where((country=='Denmark')&
                                    (date.isin(holidays.DK())),1,
                                    np.where((country=='Austria')&
                                             (date.isin(holidays.AT())),1,\
         np.where((country=='Hungary')&
                  (date.isin(holidays.HU())),1,
                  np.where((country=='Portugal')&
                           (date.isin(holidays.PT())),1,
                           np.where((country=='Norway')&
                                    (date.isin(holidays.NO())),1,
                                    np.where((country=='Portugal')&
                                             (date.isin(holidays.PT())),1,\
         np.where((country=='New Zealand')&
                  (date.isin(holidays.NZ())),1,
                  np.where((country=='South Africa')&
                           (date.isin(holidays.ZA())),1,
                           np.where((country=='South Africa')&
                                    (date.isin(holidays.ZA())),1,\
         0))))))))))))))))))))))))))),np.nan).astype(int)
     return judge_holiday
Пример #2
0
 def test_whit_monday(self):
     self.holidays = holidays.NL(years=2017)
     self.assertIn(date(2017, 6, 5), self.holidays)
Пример #3
0
    "CO": holidays.CO(),
    "MX": holidays.MX(),
    "US": holidays.US(),
    "NZ": holidays.NZ(),
    "AU": holidays.AU(),
    "DE": holidays.DE(),
    "AT": holidays.AT(),
    "DK": holidays.DK(),
    "UK": holidays.UK(),
    "IE": holidays.IE(),
    "ES": holidays.ES(),
    "CZ": holidays.CZ(),
    "SK": holidays.SK(),
    "PL": holidays.PL(),
    "PT": holidays.PT(),
    "NL": holidays.NL(),
    "NO": holidays.NO(),
    "IT": holidays.IT(),
    "SE": holidays.SE(),
    "JP": holidays.JP(),
    "BE": holidays.BE(),
    "ZA": holidays.ZA(),
    "SI": holidays.SI(),
    "FI": holidays.FI(),
    "CH": holidays.CH()
}


def get_holiday():
    country = get_country_code()
    if not country in country_holidays.keys():
Пример #4
0
 def test_liberation_day_after_1990_in_lustrum_year(self):
     self.holidays = holidays.NL(years=2020)
     self.assertIn(date(2020, 5, 5), self.holidays)
Пример #5
0
 def test_ascension_day(self):
     self.holidays = holidays.NL(years=2017)
     self.assertIn(date(2017, 5, 25), self.holidays)
Пример #6
0
 def test_kings_day_after_2014_substituted_earlier(self):
     self.holidays = holidays.NL(years=[2188])
     self.assertIn(date(2188, 4, 26), self.holidays)
Пример #7
0
 def test_liberation_day(self):
     self.holidays = holidays.NL(years=1900)
     self.assertNotIn(date(1900, 5, 5), self.holidays)
Пример #8
0
 def test_queens_day_between_1980_and_2013_substituted_earlier(self):
     self.holidays = holidays.NL(years=[2006])
     self.assertIn(date(2006, 4, 29), self.holidays)
Пример #9
0
    def test_kings_day_after_2014(self):
        self.holidays = holidays.NL(years=[2013])
        self.assertNotIn(date(2013, 4, 27), self.holidays)

        self.holidays = holidays.NL(years=[2017])
        self.assertIn(date(2017, 4, 27), self.holidays)
Пример #10
0
 def test_queens_day_between_1949_and_2013(self):
     self.holidays = holidays.NL(years=[1965])
     self.assertIn(date(1965, 4, 30), self.holidays)
Пример #11
0
 def test_queens_day_between_1949_and_1980_substituted_later(self):
     self.holidays = holidays.NL(years=[1967])
     self.assertIn(date(1967, 5, 1), self.holidays)
Пример #12
0
 def test_queens_day_between_1891_and_1948_substituted_later(self):
     # Between 1891 and 1948 Queens Day was celebrated on 9-1
     #  (one day later) when Queens Day falls on a Sunday
     self.holidays = holidays.NL(years=[1947])
     self.assertIn(date(1947, 9, 1), self.holidays)
Пример #13
0
 def test_queens_day_between_1891_and_1948(self):
     # Between 1891 and 1948 Queens Day was celebrated on 8-31
     self.holidays = holidays.NL(years=[1901])
     self.assertIn(date(1901, 8, 31), self.holidays)
Пример #14
0
 def setUp(self):
     self.holidays = holidays.NL()
Пример #15
0
 def test_second_christmas(self):
     self.holidays = holidays.NL(years=2017)
     self.assertIn(date(2017, 12, 26), self.holidays)
Пример #16
0
 def test_first_christmas(self):
     self.holidays = holidays.NL(years=2017)
     self.assertIn(date(2017, 12, 25), self.holidays)