AnalystPath

Above-Average Campuses

PandasEasyJunior level~10 min

Problem

You are given a DataFrame `menu_item` with columns `item_id`, `campus`, and `price_cents`. `item_id` is unique. Each row is one cafeteria menu item sold on a `campus`, priced in cents.

A campus is considered expensive when its average item price is strictly greater than the average item price across all campuses combined (the mean over every individual item). Return the `campus` names of the expensive campuses in a single column `campus`, sorted alphabetically ascending.

Input data

Example rows — the live problem includes the full dataset.

menu_item
item_idcampusprice_cents
1North800
2North900
3South400
4South500
5West700

Expected output

Your answer should return 2 rows with the columns campus.

Starter code (Pandas (Python))

import pandas as pd

def above_average_campuses(menu_item) -> pd.DataFrame:
    # Your code here
    return menu_item

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