Ivy Professional School
Rating
Learning/Python Data Drill #10

Hotel Booking Cancellation Analysis

Last updated

Analyze hotel bookings, cancellation risk, revenue loss, stay duration, and hotel-wise booking performance.

PythonIntermediatePandasNumPyDate HandlingHotel AnalyticsGroupBy

Your Objective

Analyze hotel bookings, cancellation risk, revenue loss, stay duration, and hotel-wise booking performance.

The Setup

Your dataset contains hotel_bookings with check-in and check-out dates, room rate, hotel type, and booking status.

Table Schema

hotel_bookings
ColumnTypeKey / Notes
booking_idINTUnique booking ID
guest_nameVARCHAR(50)Guest name
hotel_typeVARCHAR(50)Type of hotel
check_in_dateDATEGuest check-in date
check_out_dateDATEGuest check-out date
room_rateFLOATRoom rate per night
booking_statusVARCHAR(20)Booking status

Sample Data

hotel_bookings — 8 rows

booking_idguest_namehotel_typecheck_in_datecheck_out_dateroom_ratebooking_status
701AmitBusiness Hotel2024-03-012024-03-044500Completed
702NehaResort2024-03-052024-03-107500Cancelled
703RohanBudget Hotel2024-03-082024-03-102200Completed
704PriyaBusiness Hotel2024-03-122024-03-155000Completed
705KabirResort2024-03-142024-03-208200Cancelled
706IshaBudget Hotel2024-03-162024-03-182500Completed
707DevBusiness Hotel2024-03-182024-03-224800Cancelled
708MeeraResort2024-03-212024-03-257800Completed

Your Task

Calculate stay duration for each booking. Calculate potential revenue for every booking. Calculate revenue loss for cancelled bookings. Classify booking risk as High Risk, Medium Risk, or Low Risk. Summarize hotel-type-wise total bookings, completed bookings, cancelled bookings, potential revenue, and revenue loss.

Your output should look like this (partial example):

booking_idguest_namehotel_typestay_durationpotential_revenuerevenue_lossbooking_risk
701AmitBusiness Hotel3135000Low Risk
702NehaResort53750037500Medium Risk
.....................

Python Hint

  • →Convert date columns with pd.to_datetime before subtracting them.
Explore Enterprise Solutions