AnalystPath

Minimum Donation Tier That Fits Each Venue

PandasMediumMid level~10 min

Problem

You are given two DataFrames.

`venues` — one row per venue:

| Column | Type |
|----------|------|
| venue_id | int |
| seats | int |

`venue_id` is unique. `seats` is how many attendees the venue can hold.

`tiers` — one row per donation tier:

| Column | Type |
|-----------|------|
| donation | int |
| attendees | int |

`donation` is unique. Each row means: at this donation level, `attendees` people are expected to attend.

For each venue, find the smallest `donation` tier whose expected `attendees` does **not exceed** the venue's `seats` (so the crowd fits). Return `venue_id` and that minimum donation in a column named `min_donation`. If no tier fits, return `-1` for that venue. Return the result in any order.

Input data

Example rows — the live problem includes the full dataset.

venues
venue_idseats
150
2200
310
tiers
donationattendees
10030
200120
300180

Expected output

Your answer should return 3 rows with the columns venue_id, min_donation.

Starter code (Pandas (Python))

import pandas as pd

def minimum_donation_tier(venues: pd.DataFrame, tiers: pd.DataFrame) -> pd.DataFrame:
    # Your code here
    return venues

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