Assume we have the following dataframe
date = '20/09/2022'
A B
n.a. 15/02/2022
0.74 15/02/2022
0.3 ''
1 ''
1 15/02/2022
n.a. ''
and we want to do the following:
- if the value in A column is equal to 1 then fill the B column with n.a.
- if the value in A column is smaller than 1 or 'n.a'.
THEN - IF The B column is empty --> insert the variable date in that cell
- If The B column is NOT empty -->keep the value that it already has
thus our example should become the following
A B
n.a. 15/02/2022
0.74 15/02/2022
0.3 20/09/2022
1 'n.a.'
1 'n.a.'
n.a 20/09/2022