Data Science

Merging DataFrames (The Python Join)

SQL Mastery Team
May 12, 2026
5 min read

Welcome to **Phase 2: Data Wrangling**. Today is **Day 111**, and we're learning how to "Join" in Python.

The .merge() function

In SQL, you used `JOIN`. In Pandas, we use `pd.merge()`. It supports all the same types: Inner, Left, Right, and Outer.

The Syntax

# Merging orders with customers

merged_df = pd.merge(orders, customers, on='customer_id', how='left')

Why it's more flexible than SQL

  • **Different names**: If your ID columns have different names, use `left_on='id'` and `right_on='customer_id'`.
  • **Suffixes**: If both tables have a "name" column, Pandas will automatically name them `name_x` and `name_y`. You can customize this with `suffixes=('_ord', '_cust')`.
  • Your Task for Today

    Merge two DataFrames using a "Right" join and inspect the results for rows that have missing data on the left side.

    *Day 112: Concatenating and Appending Data.*

    Ready to put your knowledge into practice?

    Join SQL Mastery and learn through interactive exercises.