Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
242 views
in Technique[技术] by (71.8m points)

python - Get difference among N vectors and a reference array

I'd like to know how to search over N vectors for the differences between them and a reference vector. In other words, i want all elements of reference_arr that is not present in any of the N vectors.

Example:

reference_arr = [0,1,2,3,4,5,6,7,8,9,10]

A = [0, 4, 5]

B = [0, 10]

C = [1, 5, 7]

Desired output would be: [2,3,6,8,9]

My solution would be concatenate everything in a single vector, cast as a set to remove duplicate values and then use np.setdiff1d(). I don't know how this can scale (how many Nvectors i would have), so i can't say it's the best solution. Any guidance would be appreciated.

Thanks in advance.

question from:https://stackoverflow.com/questions/65929250/get-difference-among-n-vectors-and-a-reference-array

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...