Members Who Booked Yoga and Spin but Not Boxing
Problem
A fitness studio records every class a member books.
`members` (`members.csv`): `member_id`, `member_name` — one member per row.
`bookings` (`bookings.csv`): `booking_id`, `member_id`, `class_name` — each row is one class booking by a member.
Return the `member_id` and `member_name` of every member who has booked both the `Yoga` class and the `Spin` class but has **never** booked the `Boxing` class. Return the rows ordered by `member_id`.
Input data
Example rows — the live problem includes the full dataset.
| member_id | member_name |
|---|---|
| 1 | Priya |
| 2 | Marco |
| 3 | Elena |
| 4 | Theo |
| booking_id | member_id | class_name |
|---|---|---|
| 10 | 1 | Yoga |
| 20 | 1 | Spin |
| 30 | 1 | Pilates |
| 40 | 1 | Boxing |
| 50 | 2 | Yoga |
Expected output
Your answer should return 1 row with the columns member_id, member_name.
Starter code (Pandas (Python))
import pandas as pd
def yoga_and_spin_not_boxing(members: pd.DataFrame, bookings: pd.DataFrame) -> pd.DataFrame:
# Your code here
return membersSolve 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