使用Python在另一个数据范围内的一个数据帧中检查多行
我的要求是检查一个数据框中的所有行是否在另一个数据范围内。在这里,我有两个数据框,如下所示:
dfactual
dfepped
在这里我要检查dfactual上的dfeppent中的所有行是否存在,如果所有人都存在,则应返回true true else elle false。 我尝试了以下解决方案:
dfActual['Bool_col'] = (dfActual.merge(dfExpected,
how='left',
indicator=True)
.eval('_merge == "both"'))
但是它总是返回false。任何人都可以帮我吗?
My requirement is to check whether all the rows in one dataframe present on another. Here I have two dataframe shown as below:
dfActual
dfExpected
Here i want to check whether all the rows in dfExpected present on dfActual, if all present it should return true else false.
I have tried the below solution:
dfActual['Bool_col'] = (dfActual.merge(dfExpected,
how='left',
indicator=True)
.eval('_merge == "both"'))
But it always returns false. Could anyone please help me on this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
猜测1:您想要一条新的行,该行是否发生在另一个数据框架中。然后,您可以做这样的事情:
猜测2:
如果您只想检查一个数据框架是否发生在另一个数据框中,则可以使用以下方式:
Guess No. 1: You want a new row that identifies whether it occurs in another data frame. Then, you could do something like this:
Guess No. 2:
If you just want to check, whether one data frame occurs in another, you could use this:
它对我正常工作,您可以在我的附件映像中看到。以
< img src =“ https://i.sstatic.net/2ajlk.png” alt =“ result”>
您评论了列,然后结果还可以请参见此图像。

It is working for me correctly you can see in my attached image.Kindly check your DataFrame making mistake any where else
You comment that column then also result is ok see this image.

您可以做:
You can do: