Is there a powerful replace function in Python, something equivalent to replace(x, l, y) in R? e.g.
x = [0,0,0,0,0,0,0,0,0, 0]
l = [True,False,True,True,False,False,False,False,True, False]
y = [5, 6, 7, 8]
The number of values in y matches the number of True in l. In R, replace(x, l, y) will have x replaced by y corresponding to the True positions in l.
Is there a similar function in Python I can call? If not, any suggestions how to make it working?
Thanks much in advance!