pandas left join where right is null on multiple columns

后端 未结 1 1325
挽巷
挽巷 2021-01-12 18:29

I have two pandas df x and y, both with the same 3 columns A B C (not nullable). I need to create a new df z, obtained by \"subtracting from x the rows which are entirely id

1条回答
  •  不知归路
    2021-01-12 19:13

    I think need merge with indicator and filter only rows from left DataFrame:

    df = x.merge(y, indicator='i', how='outer').query('i == "left_only"').drop('i', 1)
    print (df)
        A   B    C
    0  q1  q2   q3
    2  q7  q2  q93
    

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