Indexing a villa against itself: a median-of-ratios holiday price index in pandas

2026-11-14来源 dev.toEnglish

How much more does a Caribbean villa cost at Christmas? Averaging Christmas prices and January prices gives a misleading answer, because the expensive homes dominate both averages and the sample is never quite the same in both weeks.

For our 2026 Christmas Week Index we compared each home with itself instead.

The setup

We asked the same rental company for the same 7 nights in three weeks:

  • Christmas week: Dec 19 to 26, 2026
  • New Year week: Dec 26, 2026 to Jan 2, 2027
  • Baseline: Jan 16 to 23, 2027

That gave 368 homes across six islands, quoted on 31 Oct 2026. 338 of them returned both a Christmas and a January quote, and the index rests on those.

The method in a few lines

import pandas as pd q = pd.read_csv("quotes.csv") # home_id, island, week, total_usd wide = q.pivot_table(index=["home_id", "island"], columns="week", values="total_usd").dropna(subset=["xmas", "jan"]) wide["xmas_ratio"] = wide["xmas"] / wide["jan"] wide["ny_ratio"] = wide["new_year"] / wide["jan"] index = (wide.groupby("island")[["xmas_ratio", "ny_ratio"]] .median() .mul(100) .round()) overall = wide[["xmas_ratio", "ny_ratio"]].median().mul(100).round() 

Because each ratio is a home's holiday rent divided by its own January rent, a $3,000-a-night house and a $900-a-night house count the same. An index of 200 means double.

What it showed

Island Christmas New Year Median 7 nights at Christmas
St. Barts 192 240 $58,139
Turks and Caicos 187 217 $96,653
Anguilla 173 197 $145,729
Barbados 160 165 $31,618
Jamaica 152 153 $44,301
Cayman Islands 152 177 $26,596

Across all islands the Christmas index is 164 and the New Year index 182. Seven weeks out, 74% of homes were already taken for Christmas week.

Things that bit us

  • Minimum stays. 55% of homes ask for more than seven nights at Christmas. We kept the 7-night rate so the ratio compares like with like, but the real stay costs more.
  • Booked homes. A booked home keeps its published rate, so it stays in the price data; "taken" is tracked as a separate column.
  • Small islands. Anguilla's index rests on 6 homes. Report the n next to every median.
  • One source. Quotes come from one agency's rate boxes. They are published prices, not what guests paid.

The island-by-island CSV is free to reuse under CC BY 4.0 at gladori.com/data/christmas-week-index.

— Gladori Editorial

原文:https://www.a8q9.cn/en/article/indexing-a-villa-against-itself-a-median-of-ratios-holiday-price-index-in-pandas-ac7a37.html

相关文章