Lay them along the third axis np.dstack
and go back to 2D
-
np.dstack((a,b)).reshape(a.shape[0],-1)
With three arrays or even more arrays, just add them. So for three arrays use: np.dstack((a,b,c))
and change the form with c
being the third array.
Run Example -
In [99]: a Out[99]: array([[8, 4, 0, 5, 6], [0, 2, 3, 0, 6], [4, 4, 0, 6, 5], [7, 5, 0, 7, 0], [6, 7, 4, 7, 2]]) In [100]: b Out[100]: array([[3, 5, 8, 6, 5], [5, 6, 8, 8, 4], [8, 3, 3, 3, 5], [2, 1, 1, 1, 3], [5, 7, 7, 5, 7]]) In [101]: np.dstack((a,b)).reshape(a.shape[0],-1) Out[101]: array([[8, 3, 4, 5, 0, 8, 5, 6, 6, 5], [0, 5, 2, 6, 3, 8, 0, 8, 6, 4], [4, 8, 4, 3, 0, 3, 6, 3, 5, 5], [7, 2, 5, 1, 0, 1, 7, 1, 0, 3], [6, 5, 7, 7, 4, 7, 7, 5, 2, 7]])