pandas 左连接,其中多列上的right为空 [英] pandas left join where right is null on multiple columns

查看:92
本文介绍了 pandas 左连接,其中多列上的right为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个熊猫df x和y,它们都具有相同的3列A B C(不可为空).我需要创建一个新的df z,通过从x减去与y的行完全相同的行"获得,即a

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 identical to the rows of y", i.e. a

x left join y on x.A=y.A and x.B=y.B and x.C=y.C
where y.A is null

我该怎么做?卡住了索引,concat,merge,join等...

How would I do that? Got stuck with indexes, concat, merge, join, ...

示例:

dataframe x
A    B    C
q1   q2   q3
q4   q2   q3
q7   q2   q9

dataframe y
A    B    C
q4   q2   q3

dataframe z
A    B    C
q1   q2   q3
q7   q2   q9

推荐答案

我认为需要

这篇关于 pandas 左连接,其中多列上的right为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆