Practice / joins

Who Ordered What

medium

The Daily Grind wants a human-readable order log — who ordered what, for drinks tied to a known customer.

You have two DataFrames:

orders

customers

Your task: for every order that has a matching customer, return the customer's name, the item, and the amount. Orders with no matching customer are dropped.

Assign your answer DataFrame to result. Row order doesn't matter.

ordersinput DataFrame

Schema
columntype
order_idlong
customer_idlong
itemstring
amountdouble
Sample rows
order_idcustomer_iditemamount
1100Latte5.5
2101Mocha6
3999Espresso3
4100Cold Brew6.25

customersinput DataFrame

Schema
columntype
customer_idlong
namestring
Sample rows
customer_idname
100Priya
101Sam
102Wei
Expected output shape
nameitemamount· 3 rows
Hint

orders.join(customers, on="customer_id", how="inner") keeps only orders with a known customer, then select("name", "item", "amount").

Lesson refresher

This problem builds on Joins (~8 min). Pop it open in a new tab if you want a quick recap.

Loading editor…
Hit Run to execute your code and see the output here.