Pandasdrill

Level 4: Combining and reshaping Exercise 29 of 45 Pro

Left merge keeps every order

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

Join `orders` to `customers` on `cust_id`, keeping every order. Orders with an unknown customer get missing name and city.

What this exercise teaches

A left merge keeps every row of the left table and fills the right table's columns with NaN where no match exists. That is the usual choice when the left table is the one you are reporting on.

A hint if you get stuck

how="left" keeps all rows from the table on the left of the merge.

This exercise is part of Pro

Pro unlocks all 45 exercises, with worked solutions and progress saved to your account. The free exercises work without an account.

You create a free account first, so Pro is attached to it.

Monthly is charged today and then every month until you cancel, in one click from your account page. Lifetime is one payment with no renewals. Full refund within 14 days of paying.

Start with the free exercises

More exercises in Combining and reshaping