Merging, Joining & Reshaping
Combining multiple DataFrames, and pivoting between long and wide.
| how= | Keeps | Example |
|---|---|---|
| only rows with a match on both sides | left has keys 1,2; right has 2,3 → result has just key 2 |
| every row from the left table, even without a match | key 1 (no match) still appears, with NaN for the right columns |
| every row from the right table | key 3 (no match on left) still appears, with NaN for the left columns |
| every row from both, matched where possible | keys 1, 2, 3 all appear; unmatched sides are NaN |
📝 Note: concat stacks DataFrames as-is (rows or columns); merge/join combine them based on matching key VALUES, like a SQL join.
Now practice it
Exercises that use what this lesson just covered.