Duplicated rows when merging dataframes in python

前端 未结 1 1289
礼貌的吻别
礼貌的吻别 2021-02-07 00:23

I am currently merging 2 dataframes with an outer join, but after merging, I see all the rows are duplicated even when the columns I did the merge upon contain the same values.

1条回答
  •  暖寄归人
    2021-02-07 01:14

    list_2_nodups = list_2.drop_duplicates()
    pd.merge(list_1 , list_2_nodups , on=['email_address'])
    

    The duplicate rows are expected. Each john smith in list_1 matches with each john smith in list_2. I had to drop the duplicates in one of the lists. I chose list_2.

    0 讨论(0)
提交回复
热议问题