1. Home
  2. Data Science
  3. Pandas
  4. What precondition does pd.merge_asof impose on both input…

Added 30 Nov -0001

What precondition does pd.merge_asof impose on both input frames?

  1. Both must share a MultiIndex, since asof merges only on index keys
  2. Both must contain no duplicate keys, because asof performs an inner join
  3. Both must be sorted by the key column, which has to hold ordered data Correct answer
  4. Both must have identical dtypes for every shared column in the frames

Correct answer

C. Both must be sorted by the key column, which has to hold ordered data

18 views

MCQSEXAM

Explanation

merge_asof matches each left key to the nearest right key at or before it, which is why both frames must be sorted on that key; otherwise pandas raises a MergeError. It is designed for unevenly sampled series such as trades against quotes, where an exact equality join would drop most rows. The tolerance argument limits how far back a match may be taken, and direction controls which side is searched.

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