Learn / Pandas
Advanced

Merging, Joining & Reshaping

Combining multiple DataFrames, and pivoting between long and wide.

how=KeepsExample

inner

only rows with a match on both sides

left has keys 1,2; right has 2,3 → result has just key 2

left

every row from the left table, even without a match

key 1 (no match) still appears, with NaN for the right columns

right

every row from the right table

key 3 (no match on left) still appears, with NaN for the left columns

outer

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.

GroupBy & AggregationTime Series & MultiIndex