Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please assist in solving the following: Let's assume that there are two service periods: Service Period 1 consists of time slots 17:30, 17:45, 18:00, 18:15

Please assist in solving the following:

Let's assume that there are two service periods:

  • Service Period 1 consists of time slots 17:30, 17:45, 18:00, 18:15
  • Service Period 2 consiss of time slots 20:45, 21:00, 21:15, 21:30

The next function takes as input res_time, which is one of the eight times above as a datetime time. Given the inputted time, you will exclusively focus this analysis on either Service Period 1 or 2. For example, if the inputted res_time is 17:45, you should only consider reservations made during Service Period 1. For each day, find the first reservation that books at res_time (datetime_booked tells you the order in which reservations were scheduled). Within the given Service Period of interest, compute how many reservations have already been booked for the given day before this reservation for res_time was made. Ifk?1reservations have already been made, this means that res_time was first booked as the k-th reservation. We will say the "rank" of reservation time res_time on this day wask. So, if res_time was the first time booked on a particular day frot he relevant Service Period, its rank on this day is 1. Return the average rank of res_time across all days in which a reservation for res_time was booked.

image text in transcribedimage text in transcribed
Notice: If there are two ranks which have the same booking time, they will have the same rank. For example, in the following table, both the first and second table share Rank 2. reservation_dat reservation_time datetime_booked rank 9/9/17 18:15:00 2017-08-15 10:03:00 9/9/17 18:00:00 2017-08-15 10:04:00 N 9/9/17 17:45:00 2017-08-15 10:04:00 N 9/9/17 17:30:00 2017-08-15 10:05:00 def Get_Avg_Rank (res_time) : df res = Read_Data ( ) avg_rank=None return avg_rank res_time = datetime . time (hour = 21, minute=30) assert np. isclose (Get_Avg_Rank (res_time) , 3.9035) res_time = datetime . time (hour = 20, minute=45) assert np. isclose (Get_Avg_Rank (res_time) , 1. 45714) res_time = datetime. time (hour = 17, minute=30) assert np. isclose (Get_Avg_Rank (res_time) , 3. 17690) res_time = datetime . time (hour = 17, minute=45) assert np. isclose (Get_Avg_Rank (res_time) , 2. 77316)In [167 ] : import pandas as pd import numpy as np import datetime import pandas as pd

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Unity From Zero To Proficiency Beginner A Step By Step Guide To Coding Your First Game

Authors: Patrick Felicia

1st Edition

1091872023, 978-1091872028

More Books

Students also viewed these Programming questions