How does pandas merge differ from pandas concat?
Correct answer
B. merge joins on shared keys; concat stacks along an axis
15 views
B. merge joins on shared keys; concat stacks along an axis
15 views
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.
Asked in: NTS, PPSC IT, Interviews
Not sure why the answer is B? Ask here and get an explanation.