I have two excel(A.xlsx,B.xlsx with same sheet name example "testdata". The data format looks like this.
Now i want to do this operation If Filed is "ADV" match the "id" of file A and B and then merge "sum" "Stat" "Matur" "Block" new cell. example 709606 a-->b Open-->open unass-->unass False-->False
Basically i want to compare the changes with respect to "Filed" field and match "id" of two fields then compare and put the changes of each other columns in new excel file.
tried few methods and it is not correct
import datacompy, pandas as pd
df1=pd.read_excel('a.xlsx','sheet1', na_values=['NA'])
df2=pd.read_excel('b.xlsx','sheet1', na_values=['NA'])
result = df2.loc[df2['Filed'].isin(df1['Filed'])]
#print(result) Filed must be Filed=ADV then do differrrence only for ADV.
result.to_excel('diff.xlsx',index=False)
second method :
compare = datacompy.Compare(
df1[df1['Filed']=='ADV'],
df2[df2['Filed']=='ADV'],
join_columns='Sum', #You can also specify a list of columns eg ['policyID','statecode']
abs_tol=0, #Optional, defaults to 0
rel_tol=0, #Optional, defaults to 0
df1_name='Original', #Optional, defaults to 'df1'
df2_name='New' #Optional, defaults to 'df2'
)
print(compare.report())
How this can be achieved.Any solution is much welcome.Both not giving any good output .I know i am not writing the logic correctly .Support is needed .Thank you.