I have two arrays (data
and final
) and I would like to compare both arrays and return (out
) the element in data
which are not in final
data:
x y z
10.2 15.2 25.2
15.2 17.2 40.2
12.2 13.2 5.2
14.2 14.2 34.2
12.2 12.2 56.2
13.2 17.2 32.2
11.2 13.2 21.2
final:
x y z
15.2 17.2 40.2
14.2 14.2 34.2
12.2 12.2 56.2
out:
x y z
10.2 15.2 25.2
12.2 13.2 5.2
13.2 17.2 32.2
11.2 13.2 21.2
This is what I have done,
out = [np.column_stack(data[k]) for k in range(len(data)) if data[k] not in final]
out = np.vstack(out)
Problem
The problem I have is, I have to perform this action of getting my out
about 10000 times (the example is just one out of 10000) and as such speed is my major concern.
Is there an efficient way to perform this?