Pandasdrill

Level 4: Combining and reshaping Exercise 28 of 45 Pro

Inner merge on a shared key

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 only orders whose customer exists. Row order and column order do not matter here.

What this exercise teaches

An inner merge keeps only keys found in both tables, so an order placed by an unknown customer id drops out. Each matching order gets that customer's name and city.

A hint if you get stuck

merge defaults to an inner join. Use on= when the key has the same name in both tables.

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