1. Home
  2. Data Science
  3. Pandas
  4. pd.concat([a, b], axis=1) is used on two frames whose…

Added 30 Nov -0001

pd.concat([a, b], axis=1) is used on two frames whose indexes overlap only partially. What is the default result?

  1. Only labels present in both frames are kept, as an inner join on the index
  2. The frames are concatenated positionally and the index is ignored, so no alignment occurs
  3. The index union is used and missing labels produce NaN, as an outer join on the index Correct answer
  4. An error is raised because the indexes are not identical, and the frames must be reindexed

Correct answer

C. The index union is used and missing labels produce NaN, as an outer join on the index

16 views

MCQSEXAM

Explanation

Concatenation alignment: concat with axis=1 aligns on the index and defaults to join='outer', so the result covers the union of labels and fills gaps with NaN. join='inner' keeps only shared labels, and verify_integrity=True raises on duplicate labels. Because alignment is by label, differing row order between the frames is harmless, unlike positional concatenation.

Reference

Asked in: NTS, PPSC IT, Interviews

Preparing for an exam?

Doubts & discussion

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