예제 #1
0
    def filter_Mexico_holidays(df, nextday):
        '''
    :Arguments:
      df: dataframe
    :Nextday:
      datetime format
      
    :Return:
      List of filtered dates using US calender
    '''
        import holidays
        #holidays in Mexico
        us_holidays = holidays.Mexico()
        hol_dates = []
        dat_frac = list((pd.bdate_range(pd.to_datetime(df_OHLC.index[-1]),
                                        next_day)).date)
        #iterate using date index
        for ii in range(len(dat_frac)):
            print(dat_frac[ii])
            if isinstance(us_holidays.get(dat_frac[ii]), str):
                hol_dates.append(dat_frac[ii])

        if hol_dates == []:
            print('No holidays')
        else:
            for ii in hol_dates:
                print('Holiday present on {}'.format(ii))

        dat_frac = sorted(
            [x for x in set(dat_frac).difference(set(hol_dates))])[1:]
        return (dat_frac, hol_dates)
# we will consider that the mothers day affects 5 days before. Because it is during the
# week that people buy the presents for the mother's day
number_of_days_after_black_friday = 3
number_of_days_before_dia_de_la_madre = 5

#Create list of dates with a 1 day step
datelist = pd.date_range(datetime(Starting_Year, 1, 1),
                         datetime(Last_Year, 1, 1)).strftime('%Y-%m-%d')

#create df from where we will write
holidays_table_df = pd.DataFrame({'ds': datelist})

#load calendars
holidays_Spain_library = holidays.Spain()
holidays_Portugal_library = holidays.Portugal()
holidays_Mexico_library = holidays.Mexico()
holidays_France_library = holidays.France()
""" Add Black Friday and Dia de la Madre """
# compute the days to add

# ----- Black Friday-----
# We predict the 4th Thursday of November which is THanksGiving
# And then we add 1 day.
# IMPORTANT! Predicting the 4th Friday Would be Different!
# 4th friday is between the 22 and 28 inclusive
# Day after 4th Thursday is between the 23 and 29 inclusive

# We consider the Weekend and cyberMonday also as
# importan (upper_window = 3)

black_friday_list = []
예제 #3
0
### STATIC VARIABLES

today = date.today()

australia_holidays = holidays.Australia()
austria_holidays = holidays.Austria()
canada_holidays = holidays.Canada()
colombia_holidays = holidays.Colombia()
czech_holidays = holidays.Czech()
denmark_holidays = holidays.Denmark()
england_holidays = holidays.England()
europeancentralbank_holidays = holidays.EuropeanCentralBank()
germany_holidays = holidays.Germany()
ireland_holidays = holidays.Ireland()
mexico_holidays = holidays.Mexico()
netherlands_holidays = holidays.Netherlands()
newzealand_holidays = holidays.NewZealand()
northernireland_holidays = holidays.NorthernIreland()
norway_holidays = holidays.Norway()
portugal_holidays = holidays.Portugal()
portugalext_holidays = holidays.PortugalExt()
scotland_holidays = holidays.Scotland()
spain_holidays = holidays.Spain()
unitedkingdom_holidays = holidays.UnitedKingdom()
unitedstates_holidays = holidays.UnitedStates()
wales_holidays = holidays.Wales()

def isDateHoliday(date, countryHolidays):
	return date in country
예제 #4
0
images = getImages(imagesPath)
if len(images) > 0:
    for image in images:
        if (os.path.exists(image)): os.remove(image)

#Set Browser Config
ch_options = getPrefs()
drive = None

#Set API variables
current_weather = Weather()
response = {}
API_KEY, CITY = API.getAPIdata()

#Search for Today's Events
mx_holidays = holidays.Mexico()
today = str(datetime.datetime.today()).split()[0]
today_holiday = mx_holidays.get(today)

if (today_holiday):  #If event exists
    search = today_holiday
    search.replace(' ', '-')
else:  #Otherwise get the current weather
    mainPage = ''
    req = requests.get(
        "http://api.openweathermap.org/data/2.5/weather?q={}&appid={}".format(
            CITY, API_KEY))
    response = json.loads(req.content)
    current_weather.main = response["weather"][0]["description"]
    current_weather.main.replace(' ', '-')
    search = current_weather.main