I want to compare the two columns in an excel sheet. names of the columns, such as file 1 and file 2. Want to add a third column with the name "diff" using the Excel formula "countifs" utilizing these two columns. If the entries in the file 1 and file 2 columns match, the diff column value should be 0 (Zero), otherwise, it should be 1. But the outcome is not what I expected. Could you please assist anyone?
here is my inputs :
file_1 file_2
G G
A B
C F
E H
A C
H E
Output Dataframe :
file_1 file_2 diff
G G 0
A B 1
C F 1
E H 0
A C 0
H E 0
Sample code :
df = pd.read_excel('file1.xlsx')
df1 = df[df['file_1'].isin(df['file_2'])]
df['diff'] = df1
print(df)