What is the difference between pandas concat and merge?

Quick Overview

Asks how pandas concat and merge differ and when to use each one to combine DataFrames. Tests understanding of axis alignment, key-based joins, how duplicate keys change row counts, and how each function handles the index.

What is the difference between pandas concat and merge?

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: easy

Interview Round: Other

In pandas, what is the difference between `pd.concat()` and `merge()`? When would you use each one? ```hint Ask how rows get paired For each function, ask what decides which row of one table lines up with which row of the other, and what that does to the row count. ``` ### What a Strong Answer Covers - What each function does: stacking along an axis versus a key-based join - How `concat` aligns the other axis, and what its `join` option changes - How `merge` matches keys, what `how` controls, and how duplicate keys change the row count - How each one treats the index - A rule of thumb for choosing between them, backed by a short example ### Follow-up Questions - What does `pd.concat([a, b], axis=1)` return when `a` and `b` have different indexes? - A left merge returns more rows than the left table had. What happened, and how would you catch it? - How do you find the rows in one table that have no match in another? - How would you combine 365 daily CSV files that share the same columns?

Overview: Asks how pandas concat and merge differ and when to use each one to combine DataFrames. Tests understanding of axis alignment, key-based joins, how duplicate keys change row counts, and how each function handles the index.

General logo
General
Nov 24, 2026
easyData ScientistOtherData Manipulation (SQL/Python)
0
0

In pandas, what is the difference between pd.concat() and merge()? When would you use each one?

What a Strong Answer Covers Guidance

  • What each function does: stacking along an axis versus a key-based join
  • How concat aligns the other axis, and what its join option changes
  • How merge matches keys, what how controls, and how duplicate keys change the row count
  • How each one treats the index
  • A rule of thumb for choosing between them, backed by a short example

Follow-up Questions Guidance

  • What does pd.concat([a, b], axis=1) return when a and b have different indexes?
  • A left merge returns more rows than the left table had. What happened, and how would you catch it?
  • How do you find the rows in one table that have no match in another?
  • How would you combine 365 daily CSV files that share the same columns?