I need to replace values in the dataframe column x. The result should look like x_new. So in detail I have to keep the values in the x column where y is 1 and 255. Between 1 and 255 I must replace the x values with the value where y is 1. The values between 255 and 1 should stay the same. So how can I get the column x_new?
I guess it could work with replace and some condition but I do not know how to combine it. I look forward for any help and hints.
My dataframe looks like e.g.:
x y z x_new
12.28 1 1 12.28
11.99 0 1 12.28
11.50 0 1 12.28
11.20 0 1 12.28
11.01 0 1 12.28
9.74 255 0 9.74
13.80 0 0 13.80
15.2 0 0 15.2
17.8 0 0 17.8
12.1 1 1 12.1
11.9 0 1 12.1
11.7 0 1 12.1
11.2 0 1 12.1
10.3 255 0 10.3