Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi! i am currently working on a python coding project and I am stuck on this last problem, any advice on how to tackle this

Hi! i am currently working on a python coding project and I am stuck on this last problem, any advice on how to tackle this or where to start would be greatly appreciated the csv can be found here : https://drive.google.com/file/d/1LYHsg1qEBGRJOrR2LcGUGUxr3RAp6na9/view?

image text in transcribed
Problem 4 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. If k - 1 reservations 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 was k. So, if res_time was the first time booked on a particular day for the 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. 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 7-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 In [ ]: def Get_Avg_Rank (res_time) : df res = Read_Data( ) avg_rank=None # YOUR CODE HERE raise NotImplementedError ( ) return avg_rank In [ ] : res_time = datetime. time (hour = 21, minute=30) assert np. isclose (Get_Avg_Rank (res_time) , 3.9035) In [ ]: res_time = datetime. time (hour = 20, minute=45) assert np. isclose (Get_Avg_Rank (res_time) , 1. 45714) In [ ]: res_time = datetime. time (hour = 17, minute=30) assert np. isclose (Get_Avg_Rank (res_time) , 3. 17690) In [ ] : res_time = datetime. time (hour = 17, minute=45) assert np. isclose (Get_Avg_Rank (res_time ) , 2. 77316)

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_2

Step: 3

blur-text-image_3

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

Modern Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions