0
Is this correct
Rotation call schedule
2 Respostas
+ 4
Please save your program in the code playground, and put a link in your question. Use the + button to Insert Code in the comment.
This way people can test your code.
Actually you should test it yourself too, and explain your question better. "Is this correct" is not meaningful if you don't say anything about what your program is supposed to do.
0
import pandas as pd
import numpy as np
import calendar
# Define the start date and end date of the schedule
start_date = pd.Timestamp('2023-05-01')
end_date = pd.Timestamp('2024-04-30')
# Create a list of all the dates in the schedule
date_range = pd.date_range(start_date, end_date, freq='D')
# Create a DataFrame to hold the schedule
schedule = pd.DataFrame(index=date_range)
# Create a list of the four employees
employees = ['Employee A', 'Employee B', 'Employee C', 'Employee D']
# Add a column for each employee to the schedule
for employee in employees:
schedule[employee] = np.nan
# Define a function to assign morning and afternoon shifts to each day
def assign_shifts(date):
day_of_week = date.day_name()
if day_of_week in ['Saturday', 'Sunday']:
return np.nan, np.nan
elif date in calendar.Canada().holidays():
return np.nan, np.nan
else:
morning_shift = employees[date.day % len(employees)]
afternoon_shift = employees[(date.day + 1) % len(employees)]