Input Explained:
I have two dataframe df1 and df2, which holds columns as mentioned below.
df1
Description Col1 Col2
AAA 1.2 2.5
BBB 1.3 2.0
CCC 1.1 2.3
df2
Description Col1 Col2
AAA 1.2 1.3
BBB 1.3 2.0
Scenario:
Have to compare df1['Description'] and df2['Description'], when both equals then have to compare df1['Col1'] with df2['Col1'] and df1['Col2'] with df2['Col2'] and produce result as expected below.
Expected Output:
Description Col1 Col2 Col1_Result Col2_Result
AAA 1.2 2.5 Pass Fail
BBB 1.3 2.0 Pass Pass
CCC 1.1 2.3 Not found in df2 Not found in df2
Tried Code: Have tried out the below mentioned codeline for above mentioned scenario but doesn't works. Throughs error "ValueError: Can only compare identically-labeled Series objects"
df1['Col1_Result'] = np.where(df1['Description']== df2['Description'],np.where(df1['Col1'] == df2['Col1'], 'Pass', 'Fail'),'Not found in df2')
df1['Col2_Result'] = np.where(df1['Description']== df2['Description'],np.where(df1['Col2'] == df2['Col2'], 'Pass', 'Fail'),'Not found in df2')
Thanks in Advance!