Python Interview Prep/Host Popularity Tiers
Airbnb logo

Host Popularity Tiers

Airbnb·medium·pandas·About 25 min in the room

listings has one row per listing: listing_id, host_id, price and number_of_reviews. Rate each HOST by the total reviews across all of their listings: New (0 reviews), Rising (1 to 5), Trending (6 to 15), Popular (16 to 40) and Hot (more than 40). Then, for each rating, find the minimum, average and maximum nightly price of the listings whose host has that rating. Return result with the columns popularity, min_price, avg_price and max_price, with the average rounded to 2 decimals. Leave out a rating no host has.

The data

listings16 rows
listing_idint64host_idint64priceint64number_of_reviewsint64
501101850
5021021202
503102953
5041031506
50510420010
5061041805
and 10 more rows

Target output

popularitymin_priceavg_pricemax_price
New859095
Rising6091.67120
Trending150173.75200
Popular99133160
Hot90231.25310

What this question tests

Tests computing a value at one level (the host) and applying it at another (the listing), then binning with clean boundaries and a named aggregation. The usual slip is rating each listing by its own reviews, which is a different question with a confident wrong answer.

More Python interview questions

  • Weeks at Number One · Spotify · easy
  • The Salary Gap · LinkedIn · easy
  • Month-over-Month Revenue · Amazon · medium
  • Back Within a Week · Amazon · medium
Python
Shift+EnterPython is starting in your browser...
Output

Starting Python...