Pandas Left Outer Join results in table larger than left table

后端 未结 3 1265
长情又很酷
长情又很酷 2020-11-29 04:32

From what I understand about a left outer join, the resulting table should never have more rows than the left table...Please let me know if this is wrong...

My left

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-29 05:06

    A small addition on the given answers is that there is a parameter named validate which can be used to throw an error if there are duplicated IDs matched in the right table:

    combined = pd.merge(a,b,how='left',left_on='id',right_on='key', validate = 'm:1')
    

提交回复
热议问题