Case study · SQL analytics

Hotel Booking Insights

Why do hotel bookings get cancelled, and what does it cost? I ran end-to-end exploratory analysis on 119,390 bookings: I cleaned them with Pandas, modelled them in PostgreSQL, and answered five business questions with SQL to inform capacity planning and risk management.

119Kbookings analysed
37.0%of all bookings were cancelled
2.3×travel agents vs. direct cancel rate
5.8M+revenue lost to city-hotel cancellations
+20%data quality after Pandas cleaning
01Question

A cancelled booking is an empty room that could have been sold. Hotel managers need to know which bookings are risky (by hotel type, season, channel, country and how far ahead they were made) so they can set deposit policies, plan capacity, overbook sensibly and spend marketing money on reliable channels. In other words, so they can manage cancellation risk instead of reacting to it.

02Approach
Step 1Kaggle CSV119,390 rows, 32 columns
Step 2Pandas cleaningCleaning and transforms, +20% data quality
Step 3PostgreSQLStructured hotel_bookings model, loaded by Python with credentials in env variables
Step 45 SQL queriesGroup, rate, bucket, rank

here's query #1, the one behind the headline number ↓

SELECT hotel AS hotel_type,
       SUM(is_canceled) AS cancellations,
       COUNT(*) AS total_bookings,
       ROUND(SUM(is_canceled) * 100.0 / COUNT(*), 2) AS cancellation_rate
FROM hotel_bookings
GROUP BY hotel
ORDER BY cancellation_rate DESC;
03Findings

What the data said

Every chart below is drawn from my query output. The raw results are at the bottom of the page.

Cancellation rate by hotel type

City hotels lose 4 in 10 bookings.

City41.7%
Resort27.8%

33,102 of 79,330 city bookings vs. 11,122 of 40,060 resort bookings.

Cancellation rate by booking channel

Travel agents and tour operators are the riskiest channel.

Direct17.5%
GDS19.2%
Corporate22.1%
TA / TO41.0%

TA/TO = travel agents & tour operators (97,870 bookings). "Undefined" (5 bookings) left out.

Bookings by arrival month

Summer peaks: August has 2.3× the bookings of January.

5.9K
8.1K
9.8K
11.1K
11.8K
10.9K
12.7K
13.9K
10.5K
11.2K
6.8K
6.8K
JFMAMJJASOND

Cancellation rate by lead time

The further ahead people book, the more likely they cancel.

0–73 d25.5%
74–14742.5%
148–22146.1%
222–29556.6%
296–36968.7%
370–44361.8%
444–51770.4%
518–59180.0%

74-day buckets from width_bucket. Buckets past 591 days hold under 200 bookings and are left out.

Highest cancellation rates by country

Countries with more than 50 bookings.

ARE84.3%
PRT56.6%
AGO56.6%
CHN46.3%
MAR42.1%
KOR41.4%
TUR41.1%
ZAF38.8%

Portugal is the one that matters: 48,590 bookings (41% of the dataset) at a 56.6% cancel rate.

So what?

City hotels need stricter policies

They cancel at 41.7% vs. 27.8% for resorts, and lose more than 5.8M in revenue to cancellations. Non-refundable rates or deposits would hit the biggest leak first.

Shift budget toward direct and corporate bookings

Direct (17.5%) and corporate (22.1%) bookings are far more reliable than travel agents (41.0%).

Treat early bookings as soft

Bookings made more than about six months out cancel more often than not, so they're safer to overbook or to back with a deposit.

Staff and price for July–August

Summer brings the most arrivals, which makes it the time for dynamic pricing and extra staff.

04Receipts

Raw query output

Straight from the terminal, so you can check the numbers above.