1. Home
  2. Data Science
  3. Pandas
  4. How does pandas merge differ from pandas concat?

Added 30 Nov -0001

How does pandas merge differ from pandas concat?

  1. concat removes duplicate rows while merging keeps them
  2. merge joins on shared keys; concat stacks along an axis Correct answer
  3. merge stacks along an axis; concat joins on shared keys
  4. merge only works on datetime indexes

Correct answer

B. merge joins on shared keys; concat stacks along an axis

15 views

MCQSEXAM

Explanation

merge performs a database-style join, matching rows from two frames on a key column and combining their columns horizontally. concat instead glues frames end to end, either adding rows when axis=0 or adding columns when axis=1, without matching on values. Confusing the two produces either unexpected duplicate rows or misaligned columns filled with NaN.

Reference

Asked in: NTS, PPSC IT, Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is B? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More Pandas MCQs

Practise all Pandas MCQs

Similar MCQs