Python Forum
Array to construct matrix - 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: Array to construct matrix (/thread-1563.html)



Array to construct matrix - Felipe - Jan-12-2017

Hi guys,

I have 3 arrays with 10 elements which I used numpy to create:

Array 1    Array 2    Array 3
    1              2             3
    1              2             3
    1              2             3
    1              2             3
    .               .              .
    .               .              .
    .               .              .


I'd like to construct a matrix 3x10 with these arrays used as columns:

|1  2  3|
|1  2  3|
|1  2  3|
|.   .   . |
|.   .   . |
|.   .   . |

In MatLab I can do this with this command: Matrix = [Array1, Array2, Array3].

I tried something similar in Python 3.5.2 but I received the type "List". I appreciate the help.

Hi guys,

I found a solution using "np.column_stack".

In the address below, I found helpful information to those who wants to migrate from MatLab to Python. XD
https://docs.scipy.org/doc/numpy-dev/user/numpy-for-matlab-users.html


RE: Array to construct matrix - micseydel - Jan-16-2017

Thanks for posting back the solution!