Back to Practice
#0041

Left Join Orders With Customers

EasyPandas15 min10 XP

Problem

Given orders and customers DataFrames, return all orders with the customer name added. Keep orders even when the customer is missing.

Why This Matters

Joins are where many data bugs start. You need to know which table controls the output rows.

Function Signature

def attach_customer_names(orders, customers):

Examples

Example 1
Inputorders customer_ids [10, 20, 99], customers include 10 and 20
Outputthree order rows, with missing name for customer 99

A left join keeps all rows from orders.

Constraints

  • Keep all order rows.
  • Join on customer_id.
  • Do not drop orders with unknown customers.
CodePython
Visible browser tests run here when available.
Testcases1 visible / 4 hidden categories
Unknown customer is kept
Inputthree orders, two known customers
Expectedthree rows after join

The missing customer produces NaN in the name column.

Hidden Test Categories
All customers knownNo customers knownRepeated customer_id in ordersColumn order differences