AnalystPath

City with Most Amenities

PandasMediumMid levelAirbnb~15 min

Problem

**[Asked at Airbnb]**

Each listing has an `amenities` column with a comma-separated list of amenities.
Find the **city with the most total amenities** across all its listings.

Return `city` and `total_amenities`.

Input data

Example rows — the live problem includes the full dataset.

listings
listing_idcityamenities
1New YorkWiFi,Pool,Gym,Kitchen
2New YorkWiFi,Kitchen,Parking
3Los AngelesWiFi,Pool
4ChicagoWiFi,Pool,Gym

Expected output

Your answer should return 1 row with the columns city, total_amenities.

Starter code (Pandas (Python))

import pandas as pd

def city_with_most_amenities(listings: pd.DataFrame) -> pd.DataFrame:
    # Your code here
    return listings

Solve this Pandas question free

Write Pandas (Python) and run it instantly in your browser — even on your phone. No signup needed to try.

Solution & explanation

Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.

Sign up free to unlock

Related Pandas questions