Inner, Left, Right, and Outer
Choosing the join that keeps the right rows.
Inner, Left, Right, and Outer is a free Data Science Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Data Science Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Two Tables, One Question
Real data rarely lives in one table. A join combines two tables into one by matching rows on a shared column.
The Key Column
Every join needs a key: the column whose values link rows across both tables, like a shared customer id.
Meet merge
In pandas you join with merge. You pass the two frames and tell it which key column to match on.
merged = orders.merge(customers, on="customer_id")Inner Keeps Matches Only
An inner join keeps only rows whose key exists in both tables. Anything unmatched simply disappears.
orders.merge(customers, on="customer_id", how="inner")Left Keeps Everything on the Left
A left join keeps every row from the left table, filling missing right-side columns with NaN when there is no match.
orders.merge(customers, on="customer_id", how="left")Right Mirrors Left
A right join keeps every row from the right table instead. It is just a left join with the tables swapped.
orders.merge(customers, on="customer_id", how="right")Outer Keeps Them All
An outer join keeps every row from both tables, pairing what it can and leaving NaN where a match is missing.
orders.merge(customers, on="customer_id", how="outer")How Decides the Rows
The how argument is the whole decision. It controls which unmatched rows survive, so pick it on purpose every time.
Inner Can Shrink Your Data
Be careful: an inner join silently drops rows with no partner, so your result can be much smaller than you expected.
Left Is the Safe Default
When you want to enrich a main table without losing any of its rows, reach for a left join first. 👍
Watch for New NaNs
After a left, right, or outer join, fresh NaN values mark the rows that had no match on the other side.
Quick Check
You want every row of your main table kept, even unmatched ones. Which join?
Recap: Four Ways to Join
You learned the four join types: inner keeps matches, left and right keep one side, and outer keeps everything. Choose with care!
Frequently asked questions
Is the “Inner, Left, Right, and Outer” lesson free?
Yes — the full text of “Inner, Left, Right, and Outer” is free to read here on the web, and the Data Science Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Data Science Academy course, upgrade to CoddyKit PRO.
What will I learn in “Inner, Left, Right, and Outer”?
Choosing the join that keeps the right rows. You practise Data Science Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Data Science Academy?
No prior experience is required. Data Science Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Inner, Left, Right, and Outer” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Data Science Academy lesson?
Yes. Every Data Science Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Inner, Left, Right, and Outer
- Merge on Keys and Indexes
- concat to Stack and Append
- Diagnose Bad Joins