简体   繁体   中英

column matching of two data frames

I am trying to match columns of 2 dataframes and getting the output as false. is there a way to find what is the "not equal" data?

code:

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

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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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