Is this correct | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

Is this correct

Rotation call schedule

16th Apr 2023, 12:54 AM
Laila Saleh
Laila Saleh - avatar
2 ответов
+ 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.
16th Apr 2023, 4:36 AM
Tibor Santa
Tibor Santa - avatar
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)]
16th Apr 2023, 12:58 AM
Laila Saleh
Laila Saleh - avatar