Given two arrays (A and B) of different shapes, I like to create an array containing the concatenation of each row from A to each row from B.
eg. Given:
A = np.array([[1, 2],
[3, 4],
[5, 6]])
B = np.array([[7, 8, 9],
[10, 11, 12]])
would like to create an array:
[[1, 2, 7, 8, 9],
[1, 2, 10, 11, 12],
[3, 4, 7, 8, 9],
[3, 4, 10, 11, 12],
[5, 6, 7, 8, 9],
[5, 6, 10, 11, 12]]
I can do this using iteration, but it is very slow, so you are looking for a combination of functions numpythat can recreate the above as efficiently as possible (input arrays A and B will contain up to 10,000 lines, therefore, to avoid nested loops).