I would like to combine N arrays of shape (I, J) into a single array of shape (I, J, N) such that the value at (i, j, n) in the final array is equal to the value of the n-th array at (i, j).
For example, let's say I have two arrays:
arr1 = [[2,3,4],
[3,4,5]]
arr2 = [[3,4,2],
[4,3,5]]
Then the final array would look like:
arr_final == [[[2,3], [3,4], [4,2]],
[[3,4], [4,3], [5,5]]]
Or, to take a more straightforward example:
arr1 = [[0,0,0],
[0,0,0]]
arr2 = [[1,1,1],
[1,1,1]]
arr3 = [[2,2,2],
[2,2,2]]
Then the final array would look like:
arr_final == [[[0,1,2], [0,1,2], [0,1,2]],
[[0,1,2], [0,1,2], [0,1,2]]]
Is there a function in Python, or more specifically Numpy, that could help me with this?
np.array((arr1, arr2))produce? A (2,i,j)? That's the usual way of combining N arrays.