I have two arrays like this:
A = [[111, ...], B = [[222, ...],
[222, ...], [111, ...],
[333, ...], [333, ...],
[555, ...]] [444, ...],
[555, ...]]
Where the first column contains identifiers and the remaining columns some data, where the number of columns of B is much larger than the number of columns of A. The identifiers are unique. The number of rows in A can be less than in B, so that in some cases empty spacer rows would be necessary.
I am looking for an efficient way to match the rows of matrix A to matrix B, so that that the result would look like that:
A = [[222, ...],
[111, ...],
[333, ...],
[nan, nan], #could be any unused value
[555, ...]]
I could just sort both matrices or write a for loop, but both approaches seem clumsy... Are there better implementations?
AandBhave equal number of rows, and an identical set of identifiers? And that the identifiers are unique?Aalways going to be sorted, or was that just how it appears in the question by chance!