1. Home
  2. Data Science
  3. Pandas
  4. What does pd.merge(left, right, how='outer'…

Added 30 Nov -0001

What does pd.merge(left, right, how='outer', indicator=True) add to the result?

  1. A boolean column showing whether the join key was unique in both of the input frames
  2. It raises an error if any of the keys fail to match, instead of reporting them in the result
  3. It sorts the result by the join key automatically and resets the index of the output
  4. A _merge column whose values are left_only, right_only or both, showing each row's origin Correct answer

Correct answer

D. A _merge column whose values are left_only, right_only or both, showing each row's origin

12 views

MCQSEXAM

Explanation

Merge diagnostics: indicator=True adds a categorical _merge column recording whether each output row came from the left frame, the right frame or a match, which makes row-count discrepancies easy to explain. Without it, an unexpected increase in rows usually means duplicate keys on one side. Use validate='one_to_many' or 'one_to_one' to fail fast on such duplication.

Reference

Asked in: NTS, PPSC IT, Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is D? 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