I have two 1D array:
a=[1 2 3]
b=[4 5 6]
How to combine them to an array c like this?
c=[[1 4]
[2 5]
[3 6]]
I have two 1D array:
a=[1 2 3]
b=[4 5 6]
How to combine them to an array c like this?
c=[[1 4]
[2 5]
[3 6]]
You can do :
a = [1, 2, 3]
b = [4, 5, 6]
np.vstack((a,b)).T
Result :
array([[1, 4],
[2, 5],
[3, 6]])
np.hstack gives array([1, 2, 3, 4, 5, 6])You can zip them together
python2
c = zip(a,b)
python3
c = list(zip(a,b))
Both pythons if you want a list in list
c = [[i, j] for i, j in zip(a, b)]