![]() |
"erlarge" a numpy-matrix to numpy-array - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Data Science (https://python-forum.io/forum-44.html) +--- Thread: "erlarge" a numpy-matrix to numpy-array (/thread-17363.html) |
"erlarge" a numpy-matrix to numpy-array - PhysChem - Apr-08-2019 Hi all! Is there a way to concatenate/append/"gluetogether" two (n*m-shaped) matrix into a single (n*m*2-shaped) array (with 3 axle), and not into an other (2n*m-shaped) or (n*2m-shaped) matrix? I found a couple of websites about putting matrixes together, but these sites were about how to do it row~ or column~wise. RE: "erlarge" a numpy-matrix to numpy-array - scidam - Apr-09-2019 So, you have two matrices of shape nxm and want to concatenate them by third axis and get one matrix of shape nxmx2 .Thats easy: import numpy as np A = np.random.rand(10, 20) B = np.random.rand(10, 20) C = np.dstack([A, B]) print(C.shape) RE: "erlarge" a numpy-matrix to numpy-array - PhysChem - Apr-09-2019 Thank you! This is exactly, what I want. |