Jul-16-2024, 08:56 AM
Hi,
As one can see in the picture, i'm trying to retrieve sets of data (V array : 1 row = 1 set) into M array.
Note data "sens" is important i.e values in yellow are expected ones, not ones in green.
I cannot use
Of course the current example has been simplified, and in a real world i'm dealing with millions of rows for M / thousands for V: performance is a keypoint
Well any hint is welcomed
Thanks for your time
Paul
As one can see in the picture, i'm trying to retrieve sets of data (V array : 1 row = 1 set) into M array.
Note data "sens" is important i.e values in yellow are expected ones, not ones in green.
I cannot use
np.intersect1d
since it looks for single values at a time, not for a set.Of course the current example has been simplified, and in a real world i'm dealing with millions of rows for M / thousands for V: performance is a keypoint

Well any hint is welcomed
Thanks for your time
Paul
import numpy as np M = np.array([[3301, 947, 898, 899, 945, 3467, 3468, 3469, 3470], [3302, 3467, 3468, 3469, 3470, 3471, 3472, 3473, 3474], [3303, 3471, 3472, 3473, 3474, 3475, 3476, 3477, 3478], [3304, 3475, 3476, 3477, 3478, 3479, 3480, 3481, 3482], [3305, 3479, 3480, 3481, 3482, 3483, 3484, 3485, 3486], [4301, 947, 898, 899, 945, 3467, 3468, 3470, 3469], [4304, 3475, 3476, 3477, 3478, 3480, 3479, 3481, 3482]]) V = np.array([[3469, 3470], [3471, 3472], [3479, 3480]]) val, M_ind, V_ind = np.intersect1d(M[:, 1::], V, assume_unique=False, return_indices=True)