I want to change the value in 1 column in the data frame based on the conditions and comparison of values in other columns.
This is the original data frame:
start end diff
0 2016-05-08 unknown 3
1 2016-05-08 2017-09-08 5
2 2018-09-01 2017-09-01 5
This is the data frame that I want:
start end diff
0 2016-05-08 unknown 3
1 2016-05-08 2017-09-08 1
2 2018-09-01 2017-09-01 -1
Basically, I want the values in diff column to remain the same if end is unknown, otherwise, I want it to be the value of year value of end - year value of start.
Can anyone suggest a piece of code?
Thanks in advance!