Customers who never ordered
A pandas exercise from Pandasdrill. Solve it with a Python editor in your browser running real pandas, and it is checked the moment you submit.
The task
The account team wants to call every customer who has never placed an order of any kind. Return their rows from `customers`, with all three columns.
What this exercise teaches
isin marks the customers that appear in orders, and ~ flips the mask to the ones that do not. This is an anti-join, the pandas answer to LEFT JOIN ... WHERE orders.customer IS NULL. A customer with only a cancelled order has still placed an order, so they stay off the list.
A hint if you get stuck
You are looking for customers whose name does not appear in the orders table at all.
Try it now, free, no account needed
Your first 8 exercises on Pandasdrill are free. Open it on the practice page, solve it, and get instant feedback with a hint. A free account adds the worked solution; Pro unlocks every exercise, timed mode and the certificate.
Open this exerciseMore exercises in Interview cases
- Revenue by country
- Repeat customers
- Month over month revenue growth
- Best-selling product in each region
- Average order value by segment
- New customers per month
- Second order within 30 days
- A join that inflates the total
- Top three customers and their share
- Value lost to cancellations
- Average days between orders
- Messy export: clean, then total
- New and returning customers per month
- A conversion funnel