I think I'm missing something obvious. I want to find a cartesian product of arr1 (a 1d numpy array), and the ROWS of arr2 (a 2d numpy array). So, if arr1 has 4 elements and arr2 has shape (5,2), the output should have shape (20,3). (see below)
import numpy as np
arr1 = np.array([1, 4, 7, 3])
arr2 = np.array([[0, 1],
                 [2, 3], 
                 [4, 5],
                 [4, 0],
                 [9, 9]])
The desired output is:
arr3 = np.array([[1, 0, 1],
                 [1, 2, 3], 
                 [1, 4, 5],
                 [1, 4, 0],
                 [1, 9, 9],
              
                 [4, 0, 1],
                 [4, 2, 3], 
                 [4, 4, 5],
                 [4, 4, 0],
                 [4, 9, 9],
               
                 [7, 0, 1],
                 [7, 2, 3], 
                 [7, 4, 5],
                 [7, 4, 0],
                 [7, 9, 9],
              
                 [3, 0, 1],
                 [3, 2, 3], 
                 [3, 4, 5],
                 [3, 4, 0],
                 [3, 9, 9]])
I've been trying to use transpose and reshape with code like np.array(np.meshgrid(arr1,arr2)), but no success yet.
I'm hoping the solution can be generalized because I also need to deal with situations like this: Get all combinations of the ROWS of a 2d (10,2) array and the ROWS of a 2d array (20, 5) to get an output array (200,7).