I would like to more beautifully create arr3 from arr. I will mark the solution which is most elegant and efficient for a large number of rows (~10^7) as the accepted answer.
>>> arr = np.array([3,30])
>>> arr
array([ 3, 30])
>>> arr2 = np.array([np.linspace(arr[i]/3, arr[i], 3).reshape(-1,1)
for i in range(len(arr))])
>>> list(arr2)
[array([[1.],
[2.],
[3.]]),
array([[10.],
[20.],
[30.]])]
>>> arr3 = np.tile(arr2,4)
>>> list(arr3)
[array([[1., 1., 1., 1.],
[2., 2., 2., 2.],
[3., 3., 3., 3.]]),
array([[10., 10., 10., 10.],
[20., 20., 20., 20.],
[30., 30., 30., 30.]])]
I believe creating a higher dimensional array from np.linspace can get immediately to arr2 and maybe even arr3 but I am not sure how, though you don't have to use np.linspace if this is not the best way.
Second question: If the inner two arrays of arr3 were instead required to be transposed, how would this be achieved directly from arr? It is simple from arr3 but perhaps there is a more direct way analogous to the original problem.
Thank you!