[英]Python Pandas compare 2 columns
Just wondering if anyone knows about comparing 2 df columns on python?只是想知道是否有人知道比较 python 上的 2 个 df 列?
For example i have Column 1 a1 a2例如我有第 1 列 a1 a2
a3 a3
Column 2 a123 a55 a21第 2 栏 a123 a55 a21
Is there any way that I could show a1 - Found in column 2 a2 - Not Found a3 - Found in column 2有什么方法可以显示 a1 - 在第 2 列中找到 a2 - 未找到 a3 - 在第 2 列中找到
I have my 2 columns in dataframes (df and df1)我在数据框中有 2 列(df 和 df1)
Use .isin
.使用.isin
。
df['1'].isin(df['2'])
Returns a Boolean series返回 Boolean 系列
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.