daily log 10-08-20

2 minute read

import pandas as pd

df = pd.read_csv('VG_P9_employees.csv')

## ==========================================================
## ADDING DAY COLUMNS
## ==========================================================
## --- DAYS --- Which days work for which people?

monday_ok = {'Mon-Thu,\nEvery other Fri': True,
 'Mon-Fri': True,
 'Mon-Thu': True,
 'Fri-Sun': False,
 'Fri-Sat': False,
 'Thu-Mon': False,
 'Tue-Fri': False}

tuesday_ok = {'Mon-Thu,\nEvery other Fri': True,
 'Mon-Fri': True,
 'Mon-Thu': True,
 'Fri-Sun': False,
 'Fri-Sat': False,
 'Thu-Mon': False,
 'Tue-Fri': True}

wednesday_ok = {'Mon-Thu,\nEvery other Fri': True,
 'Mon-Fri': True,
 'Mon-Thu': True,
 'Fri-Sun': False,
 'Fri-Sat': False,
 'Thu-Mon': False,
 'Tue-Fri': True}

thursday_ok = {'Mon-Thu,\nEvery other Fri': True,
 'Mon-Fri': True,
 'Mon-Thu': True,
 'Fri-Sun': False,
 'Fri-Sat': False,
 'Thu-Mon': True,
 'Tue-Fri': True}

friday_ok = {'Mon-Thu,\nEvery other Fri': False,
 'Mon-Fri': True,
 'Mon-Thu': False,
 'Fri-Sun': True,
 'Fri-Sat': True,
 'Thu-Mon': True,
 'Tue-Fri': True}

df['monday_ok'] = df.apply(lambda x: monday_ok[x['Day']], axis=1)
df['tuesday_ok'] = df.apply(lambda x: tuesday_ok[x['Day']], axis=1)
df['wednesday_ok'] = df.apply(lambda x: wednesday_ok[x['Day']], axis=1)
df['thursday_ok'] = df.apply(lambda x: thursday_ok[x['Day']], axis=1)
df['friday_ok'] = df.apply(lambda x: friday_ok[x['Day']], axis=1)


## ==========================================================
## ADDING PST TIME
## ==========================================================
## --- TIMES --- Which time slots work for which people?
## --- NOTE: Adjusted everything to PST


buildings = pd.read_csv('VG_P9_buildingtostate.csv')
buildings_to_state = dict(zip(buildings['building'], buildings['state']))

df['state'] = df.apply(lambda x: buildings_to_state[x['Location']], axis=1)

nm_time = {'7:00am 4:30pm': '8:00am 5:30pm',
 '8:00am 4:30pm': '9:00am 5:30pm',
 '6:00am 4:30pm': '7:00am 5:30pm',
 '5:00pm 3:30am': '6:00pm 4:30am',
 '5:00am 6:00pm': '6:00am 7:00pm',
 '3:30pm 2:00am': '4:30pm 3:00am',
 '3:30pm 1:00am': '4:30pm 2:00am',
 '2:00pm 10:30pm': '3:00pm 11:30pm'}

def get_pst_time(state, start_end):
    if state == 'CA':
        return start_end
    if state == 'NM':
        return nm_time[start_end]
    if state == 'London':
        return '4:00pm 12:30am'

df['start_end'] = df.apply(lambda x: x['Start Time'] + " " +  x['End Time'], axis=1)
df['start_end_PST'] = df.apply(lambda x: get_pst_time(x['state'], x['start_end']), axis=1)


## ==========================================================
## ADDING SHIFT TIMES
## ==========================================================

## ----- PREF TIME ONE --------------------------------------

# MEETINGS FROM 12-2
# Pref_time_1A = 12-1
# Pref_time_1B = 1-2

# MEETINGS FROM 12-1

pref_time_1_ok = {'7:00am 4:30pm': True,
 '8:00am 4:30pm': True,
 '6:00am 4:30pm': True,
 '5:00pm 3:30am': False,
 '5:00am 6:00pm': True,
 '3:30pm 2:00am': False,
 '3:30pm 1:00am': False,
 '2:00pm 10:30pm': False}

pref_time_1A_ok = {'7:00am 4:30pm': True,
 '8:00am 4:30pm': True,
 '6:00am 4:30pm': True,
 '5:00pm 3:30am': False,
 '5:00am 6:00pm': True,
 '3:30pm 2:00am': False,
 '3:30pm 1:00am': False,
 '2:00pm 10:30pm': False}

# MEETINGS FROM 1-2
pref_time_1B_ok = {'7:00am 4:30pm': True,
 '8:00am 4:30pm': True,
 '6:00am 4:30pm': True,
 '5:00pm 3:30am': False,
 '5:00am 6:00pm': True,
 '3:30pm 2:00am': False,
 '3:30pm 1:00am': False,
 '2:00pm 10:30pm': False}

## ----- PREF TIME TWO --------------------------------------

# MEETINGS FROM 2-4:30
# ?
# Pref_time_2B = 3:30-4:30

pref_time_2_ok = {'7:00am 4:30pm': True,
 '8:00am 4:30pm': True,
 '6:00am 4:30pm': True,
 '5:00pm 3:30am': False,
 '5:00am 6:00pm': True,
 '3:30pm 2:00am': False,
 '3:30pm 1:00am': False,
 '2:00pm 10:30pm': True}

pref_time_2A_ok = {'7:00am 4:30pm': True,
 '8:00am 4:30pm': True,
 '6:00am 4:30pm': True,
 '5:00pm 3:30am': False,
 '5:00am 6:00pm': True,
 '3:30pm 2:00am': False,
 '3:30pm 1:00am': False,
 '2:00pm 10:30pm': True}

pref_time_2B_ok = {'7:00am 4:30pm': True,
 '8:00am 4:30pm': True,
 '6:00am 4:30pm': True,
 '5:00pm 3:30am': False,
 '5:00am 6:00pm': True,
 '3:30pm 2:00am': True,
 '3:30pm 1:00am': True,
 '2:00pm 10:30pm': True}

## ----- PREF TIME 'SECOND SHIFT' ----------------------------

# MEETING FROM 4:30-5:30
pref_time_second_shift_ok = {'7:00am 4:30pm': False,
 '8:00am 4:30pm': False,
 '6:00am 4:30pm': False,
 '5:00pm 3:30am': False,
 '5:00am 6:00pm': True,
 '3:30pm 2:00am': True,
 '3:30pm 1:00am': True,
 '2:00pm 10:30pm': True}

df['pref_time_1_ok'] = df.apply(lambda x: pref_time_1_ok[x['start_end']], axis=1)
df['pref_time_2_ok'] = df.apply(lambda x: pref_time_2_ok[x['start_end']], axis=1)
df['pref_time_second_shift_ok'] = df.apply(lambda x: pref_time_second_shift_ok[x['start_end']], axis=1)
taken = {}


# def get_mg_id():

def assign_mg_id():
    test = random.randint(1,7)
#     print(test)
    if test in taken:
        if taken[test] > 7:
            print(test)
#             assign_mg_id()
        else:
            taken[test] = taken[test] + 1
            return test

    else:
        taken[test] = 1

#     if taken[test] > 8:


#     else:
#         return test





m2C_friday_no['mg_id'] = m2C_friday_no.apply(lambda x: assign_mg_id(),axis=1)