I am trying to replace one column by another if the values in that column are equal to a string. The value of this string is "wo". If this shows up in column y, replace by column x. Currently I use the following code:
df.y.replace("wo",df.x)
This runs for a very long time (millions of observations, equals days of calculations).
Is there a more efficient way to replace ?
Just in case, the data looks as follows:
y x other variables
1 mo something
2 2 something
3 3 something
wo >5 something
4 4 something
wo 7 something
It has to look like:
y x other variables
1 mo something
2 2 something
3 3 something
>5 >5 something
4 4 something
7 7 something