So you have a list of arrays:
In [3]: alist = [np.array([1,0,0,1]) for i in range(3)]
In [4]: alist
Out[4]: [array([1, 0, 0, 1]), array([1, 0, 0, 1]), array([1, 0, 0, 1])]
Join them to become rows of a 2d array:
In [5]: np.vstack(alist)
Out[5]:
array([[1, 0, 0, 1],
[1, 0, 0, 1],
[1, 0, 0, 1]])
to become columns:
In [6]: np.column_stack(alist)
Out[6]:
array([[1, 1, 1],
[0, 0, 0],
[0, 0, 0],
[1, 1, 1]])
You comment code is unclear, but:
for i in range(6):
np.column_stack((arrays[i]))
doesn't make sense, nor does it follow column_stack
docs. column_stack
makes a new array; it does not operate in-place. List append
does operate inplace, and is a good choice when building a list iteratively, but it should not be taken as a model for building arrays itertively.
All the concatenate
and stack
functions takes a list of arrays as input. Take advantage of that. And remember, they return a new array on each call. (that applies for np.append
as well, but I discourage using that).
Another option in the stack
family:
In [7]: np.stack(alist, axis=1)
Out[7]:
array([[1, 1, 1],
[0, 0, 0],
[0, 0, 0],
[1, 1, 1]])