Block 28: Merge, Join & Concat
Combine multiple DataFrames together.
Concepts
- pd.concat() for stacking rows/columns
- pd.merge() with how: inner, left, right, outer
- merge on: single key, multiple keys
- Handling duplicate column names after merge
Code Examples
See exercise below.
Exercise
Create two small DataFrames (students and their scores) and merge them on 'student_id'. Stack three DataFrames of monthly sales data using pd.concat.
Homework
Describe the difference between inner and left join with a 5-row example. Friday