Python masking of 1d array -


say have 2 numpy arrays

a = [0, 2, 4, 6] 

and

b = [0.03, 0.78, 0.25, 0.47, 0.98, 0.58, 0.63] 

i want return 3rd array checks indices of array in b , returns value of indices in b below:

c = [0.3, 0.25, 0.98, 0.63] 

i have tried

for in range(len(b)): if b[i] == a.any():     c=[i] 

but 0's.

simply use

c = b[a] 

this view b, if change c, change b. if don't want this, use .copy()

c = b[a].copy() 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -