def dashboard_data_card3(self, student_id: int):
        transaction_mgr = TransactionalManager()
        db_conn = transaction_mgr.GetDatabaseConnection("READWRITE")
        attendance_dao = AttendanceDao(db_conn)
        card3_data_absent_days = attendance_dao.dashboard_card3_absent_days(
            student_id)
        for absent_days_record in card3_data_absent_days:
            absent_days_record['attendance_date'] = absent_days_record[
                'attendance_date'].strftime('%Y-%m-%d')
        card3_data_late_days = attendance_dao.dashboard_card3_late_days(
            student_id)
        for late_days_record in card3_data_late_days:
            late_days_record['attendance_date'] = late_days_record[
                'attendance_date'].strftime('%Y-%m-%d')

        holiday_list = []
        for ptr in holidays.India(years=2020).items():
            holiday_list.append(ptr[0].strftime('%Y-%m-%d'))
        card3_data_holidays = holiday_list
        card3_data = {
            "absent_days": card3_data_absent_days,
            "late_days": card3_data_late_days,
            "holidays": card3_data_holidays
        }
        return card3_data
 def formatday(self, day, i):
     hol = holidays.India(years=self.year)
     d = ''
     hol = hol.get(
         str(self.month) + '-' + str(day) + '-' +
         str(self.year), '') if day != 0 else ''
     if hol and day != 0:
         return f"<td class='date-hol'><span class='date'>{day}{hol}</span></td>"
     if day != 0 and (i != 5 and i != 6):
         return f"<td ><a href='?month={self.year}-{self.month}&date={day}'><span class='date'>{day}</span></a></td>"
     elif day != 0:
         return f"<td class='date-weekend'><span >{day}</span></td>"
     return f"<td class='date-empty'></td>"
Exemple #3
0
    def color_leave(self):
        import pandas as pd
        import holidays
        import datetime

        DF = pd.read_excel('leave.xlsx')
        DF2 = DF[DF['EmpID'] == int(self.emp_id)]
        L1 = list(DF2['Leave_Date'])
        L2 = []
        var = datetime.datetime.now()
        var1 = var.strftime('%Y')
        for ptr in holidays.India(years=int(var1)).items():
            L2.append(ptr[0].strftime('%d-%m-%Y'))
        return L1, L2  #first list in tuple will be Employee Holidays(green) and second one is National Holidays(RED)
Exemple #4
0
def dateinsert(final_result):
    print(final_result)
    x = datetime.date.today()

    holiday = holidays.India()

    cnt = 0
    lst = []
    for i in range(1, 18):
        x += datetime.timedelta(days=1)
        if x.weekday() < 5 and x not in holiday:
            cnt = cnt + 1
            lst.append(str(x))
            print(str(x))
        if cnt > 4:
            break
    print(lst)
    final_result.insert(0, "Date", lst, True)
    return final_result
Exemple #5
0
def journey(df):
    df_temp = df.copy(deep=True)
    india_holidays = holidays.India()
    df_temp[['Date_of_Journey']] = pd.to_datetime(df_temp['Date_of_Journey'])
    df_temp['Holiday'] = (
        df_temp['Date_of_Journey'].isin(india_holidays)).astype(int)

    if len(list(df_temp['Holiday'].unique())) < 2:
        df_temp = dropper(df_temp, 'Holiday')
        print('There are no Holidays!!!')

    df_temp['Journey Date'] = df_temp['Date_of_Journey'].dt.day
    df_temp['Journey Month'] = df_temp['Date_of_Journey'].dt.month
    #     df_temp['Journey Year']=df_temp['Date_of_Journey'].dt.year
    df_temp['Journey Day'] = df_temp['Date_of_Journey'].dt.dayofweek
    df_temp['Journey Weekend'] = np.where(
        ((df_temp['Date_of_Journey']).dt.dayofweek) > 5, 1, 0)
    df_temp['Journey Week'] = df_temp['Date_of_Journey'].dt.week

    # display(df_temp.head())

    return df_temp
 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
"""
Created on Sun Sep 29 16:23:15 2019

@author: hrudat
"""

import requests, zipfile, os, io,glob, pandas as pd
from datetime import datetime,timedelta,date
import holidays
import pandas as pd
import xlrd as xld

# Code to check public holiday in this case it's India You can extract data for other countries

FD = date.today() 
India_holidays = holidays.India()

if FD in India_holidays:
    yesterday = datetime.now() - timedelta(days=1)
else:
    yesterday = datetime.now()

# File Download code
mydate = datetime.now()
mth=mydate.strftime("%b")
ustr=str(mth)
Y = str(yesterday.year)
D = str(yesterday.day)
M = ustr.upper()

D1 =  yesterday.day
Exemple #8
0
 def isHoliday(self, date):
     india_holidays = holidays.India(years=datetime.datetime.now().year)
     return (date in india_holidays)
Exemple #9
0
            lan = takeCommand()
            translator = Translator(to_lang=lan)
            t = translator.translate(d)
            print(t)
            speak(t)
        elif 'linear equation' in query.lower():
            speak("what is the equation?")
            equation = input("Enter the equation:  ")
            m = GEKKO()
            x = m.Var()
            y = m.Var()
            m.Equation(equation)
            m.solve(disp=False)
            print(x.value, y.value)
        elif 'holidays' in query.lower():
            india = holidays.India(years=2020).items()
            if datetime.datetime.now() in india:
                speak('Sir it is holiday')
            else:
                speak('Sir we do not have a holiday ')

        elif 'change voice' in query.lower():
            engine.setProperty('voice', voices[1].id)
            speak('Hello sir')
        elif 'meeting' in query.lower():

            x = 978
            y = 506

            def sign_in(meeting_id, paswd):
                os.startfile('C:/Users/Jay/AppData/Roaming/Zoom/bin/Zoom')
# -*- coding: utf-8 -*-
"""
Created on Sat Nov  2 20:28:38 2019

@author: 91998
"""

import numpy as np
import pandas as pd
import holidays

holiday_list = holidays.India(years=2016)

train_data = pd.read_csv(r"D:\Narendra\Hitachi data Engineer Challenge\DataSet/train.csv")
test_data = pd.read_csv(r"D:\Narendra\Hitachi data Engineer Challenge\DataSet/test.csv")

print(train_data.shape, test_data.shape)
print(train_data.columns, test_data.columns)
train_data['current_date'] = pd.to_datetime(train_data['current_date'])
train_data['current_time'] = pd.to_datetime(train_data['current_time'])
train_data['hour'] = train_data['current_time'].dt.hour
train_data['current_month'] = train_data['current_date'].dt.month.astype(int)

test_data['current_date'] = pd.to_datetime(test_data['current_date'])
test_data['current_time'] = pd.to_datetime(test_data['current_time'])
test_data['hour'] = test_data['current_time'].dt.hour
test_data['current_month'] = test_data['current_date'].dt.month.astype(int)

#weather_train_csv['Season'] = 
def get_season(month, day):
    if month in (1, 2, 3):
Exemple #11
0
                        __           __  ____
              ___  ____/ /___ ______/ /_/ __ \\__  __
             / _ \\/ __  / __ `/ ___/ __/ /_/ / / / /
            /  __/ /_/ / /_/ / /  / /_/ ____/ /_/ /
            \\___/\\__,_/\\__,_/_/   \\__/_/    \\__, /
                                           /____/

'''
Notify.heading(HEADING)

##############################################################

# set time zone
TZ = pytz.timezone('Asia/Calcutta')
# set holidays
INDIA_HOLIDAYS = holidays.India()
# set market open time
OPEN_TIME = datetime.time(hour=9, minute=15, second=0)
# set market close time
CLOSE_TIME = datetime.time(hour=15, minute=30, second=0)

##############################################################

# only those stocks will be considered whose price is above threshold
PENNY_STOCK_THRESHOLD = 50
# number of stocks to select relevant ones from
NUM_OF_STOCKS_TO_SEARCH = 100
# number of stocks to focus trading on
NUM_OF_STOCKS_TO_FOCUS = 5
# percentage buffer to be set for stop loss/trade exit
BUFFER_PERCENT = 0.06