The requirement is to compare 2 dataframe(dataset) both having different header. Basically I am querying database(HANA) table and comparing its output with the output of a SQL code as data testing
Ex
df1:
customerNo City Amount
C1 ABC 100
C2 XYZ 50
df2:
customer Place Amount
C1 ABC 100
C2 PQR 40
Although column names are different but they are in the correct order. Is there a way to compare dataset just based on column orders?
I tried datacompy.Compare(df1,df2, on_index=True)
but its not working.
Try renaming the columns and then running your compare tests. An example for renaming columns:
df2 = df2.rename(columns = {'customer':'customerNo','Place':'city','Amount':'Amount'})
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.