简体   繁体   English

两个数据框的列匹配

[英]column matching of two data frames

I am trying to match columns of 2 dataframes and getting the output as false.我正在尝试匹配 2 个数据帧的列并将 output 设置为 false。 is there a way to find what is the "not equal" data?有没有办法找到什么是“不相等”的数据?

code:代码:

rounds2['company_permalink'].equals(companies['permalink'])

output: output:

  False
  
    

if i have understood the question:如果我理解了这个问题:

data1 = {'col_1': [22, 34, 23, 43], 'col_2': ['a', 'b', 'c', 'd']}
data2 = {'col_1': [22, 66, 23, 88], 'col_2': ['x', 'b', 'c', 'y']}

df1 = pd.DataFrame.from_dict(data1)
df2 = pd.DataFrame.from_dict(data2)


not_equal_col1 = df1['col_1']!=df2['col_1']
print(df1[not_equal_col1])
print(df2[not_equal_col1])

Output: Output:

   col_1 col_2
1     34     b
3     43     d
   col_1 col_2
1     66     b
3     88     y

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM