I’ve 2 data frames which have one common column ‘X’ having all the unique values. I want to subtract each column of data frame 1 to that of data frame 2 which have similar names. dataframe 1
X | bar A | bar B |
---|---|---|
A1 | 48.0 | 1235 |
A2 | 53.0 | 4567 |
dataframe 2
X | par A | par B |
---|---|---|
A2 | 74.0 | 8342 |
A1 | 63.0 | 6531 |
Desired result:
X | bar A | par A | Difference | Status |
---|---|---|---|---|
A1 | 48.0 | 63.0 | 15.0 | Ok |
A2 | 53.0 | 74.0 | 21.0 | Ok |
To be noted that Difference here refers to barA - parA I.e subtraction. and this kind of data frames are required for each column There are 20 columns in my data frames. The status column gets not ok when value is less Than 0.
I’m thinking of writing a for loop to perform this but unable to start. If anyone can help in this. Ps I’m working on python.