Cell wise concatenation of python arrays

  arrays, concatenation, functools, numpy, python

I have multiple arrays of equal size, and I want to concatenate the values in each cell to produce an output array of the same size, but where each element is a list. How can I do this?

Example.

Input:
a = [[1,2],
     [3,4]]
b = [[5,6],
     [7,8]]

Desired output:
c = [[[1,5],[2,6]],
     [[3,7],[4,8]]]

How can I achieve this? My arrays are actually np arrays, if that helps

Source: Python Questions

LEAVE A COMMENT