I have the following df:
Date 1a 1b
112 2022-10-17 3.18 2.11
298 2022-10-16 4.26 7.00
340 2022-10-16 11.66 7.80
379 2022-10-16 15.78 2.13
What I want (without a loop) to check for each row the value in 1b is larger than the value in 1a. And if so, I want to add a new column with the difference between the two. So, I want to obtain the following df:
Date 1a 1b difference
112 2022-10-17 3.18 2.11 0
298 2022-10-16 4.26 7.00 2.74
340 2022-10-16 11.66 7.80 0
379 2022-10-16 15.78 2.13 0
How can I do this?