I have a DataFrame with two columns X and Y:
X Y
0 0 111.0
1 3 NaN
2 1 NaN
3 1 112.0
4 2 113.0
5 2 NaN
6 3 114.0
7 3 115.0
8 1 NaN
9 2 116.0
I want to copy in Y only the values of X that correspond to the rows where a NaN is. The expected result should look like this
X Y
0 0 111
1 3 3
2 1 1
3 1 112
4 2 113
5 2 2
6 3 114
7 3 115
8 1 1
9 2 116
Is there any way to achieve this?