Bind columns (from vectors) to numpy

Codes are as follows:

a = numpy.zeros(3) b = numpy.ones(3) bind_by_column((a,b)) => [[0,1],[0,1],[0,1]] 

I checked this one but could not find an answer

Does anyone have any ideas about this?

+6
source share
2 answers

You can use numpy.vstack() :

 >>> import numpy >>> a = numpy.zeros(3) >>> b = numpy.ones(3) >>> numpy.vstack((a,b)).T array([[ 0., 1.], [ 0., 1.], [ 0., 1.]]) 
+5
source

np.column_stack

see Numpy: Combining multidimensional and one-dimensional arrays

 >>> import numpy >>> a = numpy.zeros(3) >>> b = numpy.ones(3) >>> numpy.column_stack((a,b)) array([[ 0., 1.], [ 0., 1.], [ 0., 1.]]) 
+10
source

All Articles