Skip to content

24. Customers Without Orders

Difficulty: Medium · Topics: Joins, Filtering & Selection

You have two DataFrames: customers and orders.

Return the name of every customer who has never placed an order.

Row order does not matter; column names must match. Your code is graded on 3 test cases, including hidden edge cases.

Sample data

customers

customer_idname
1Asha
2Ben
3Chitra
4Dev

orders

order_idcustomer_idamount
1011250
1021400
1033120

Expected output

name
Ben
Dev

Hints

Hint 1A left_anti join keeps left rows that have no match on the right.
Hint 2Join on the shared key: customers.join(orders, "customer_id", "left_anti").
Hint 3Alternative: left join, then filter rows where an orders column isNull().

Learn the concepts

PySpark functions you'll practise

Related problems

Browse

Topics: Window Functions · Joins · Aggregations · Pivot, Unpivot & Rollup · Arrays · Null Handling · Conditional Logic · Dates · Filtering & Selection · Strings · Data Lake · Lakehouse · Streaming · Data Prep for AI · Spark Performance

Difficulty: Easy · Medium · Hard · Learn · All problems · dbt practice