What precondition does pd.merge_asof impose on both input frames?
Correct answer
C. Both must be sorted by the key column, which has to hold ordered data
18 views
C. Both must be sorted by the key column, which has to hold ordered data
18 views
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.
Asked in: NTS, PPSC IT, Interviews
Not sure why the answer is C? Ask here and get an explanation.