Imagine you have the following two dfs:
lines
line amount#1 line amount#2
0 18.20 0.82
1 NaN NaN
2 40.00 259.00
3 388.00 NaN
4 17.41 NaN
btws
btw-amount#1 btw-amount#2
0 0.0 0.14
1 NaN NaN
2 NaN NaN
3 NaN NaN
4 NaN NaN
I want to subtract these two dfs such that there is a new df that is like the following:
line amount#1 line amount#2
0 18.20 0.68
1 NaN NaN
2 40.00 259.00
3 388.00 NaN
4 17.41 NaN
I've tried:
lines.subtract(btws, axis =0)
However, everyting turns NaN.
Please help!
result = lines.to_numpy() - btws.to_numpy()
result = pd.DataFrame(result, columns=lines.columns)
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.