python - Choose elements from two numpy arrays at random -
i trying merge 2 numpy arrays choosing elements each @ random. have 2 arrays of equal length x , y follows:
x = np.arange(10) y = np.arange(10, 20) and mask r:
r = np.random.choice([true, false], 10) then there way select elements x r true , y r false?
i don't have use mask approach, need fast x , y longer 10 in reality ideally no looping involved.
how this?
z = y.copy() z[r] = x[r]
Comments
Post a Comment