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

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -