0PricingLogin
Data Science Academy · Lesson

Merge on Keys and Indexes

Joining by columns or by index.

Same Name, One Word

When both tables share a column with the same name, on is all you need to merge them together.

orders.merge(customers, on="customer_id")

Join on Many Keys

Sometimes one column is not enough. Pass a list to on and pandas matches rows on every key at once.

sales.merge(targets, on=["region", "month"])

All lessons in this course

  1. Inner, Left, Right, and Outer
  2. Merge on Keys and Indexes
  3. concat to Stack and Append
  4. Diagnose Bad Joins
← Back to Data Science Academy