Why can a customer-key merge increase the row count?

pandas.merge pairs rows on matching keys. A key repeated on both sides contributes one result for every matching pair.

merge in practice

Two orders for A and three addresses for A yield six rows. If each customer should have one address, validate='many_to_one' makes a duplicate fail the merge.

中文

两个表按客户编号合并,行数为何会增加?

pandas.merge 按键配对记录。同一个键在两侧各出现多次时,每一种配对都会保留。

merge 应用实例

编号 A 在订单表出现两次,在地址表出现三次,结果有六行。若地址表应当每人一行,可用 validate='many_to_one' 及早发现重复记录。

References / 参考来源

Keep reading / 继续阅读