代码是这样的:
a = numpy.zeros(3)
b = numpy.ones(3)
bind_by_column((a,b))
=> [[0,1],[0,1],[0,1]]
我查了this但没找到答案
有没有人有这方面的想法?
答案 0 :(得分:10)
np.column_stack
见 Numpy: Concatenating multidimensional and unidimensional arrays
>>> import numpy
>>> a = numpy.zeros(3)
>>> b = numpy.ones(3)
>>> numpy.column_stack((a,b))
array([[ 0., 1.],
[ 0., 1.],
[ 0., 1.]])
答案 1 :(得分:6)
您可以使用numpy.vstack()
:
>>> import numpy
>>> a = numpy.zeros(3)
>>> b = numpy.ones(3)
>>> numpy.vstack((a,b)).T
array([[ 0., 1.],
[ 0., 1.],
[ 0., 1.]])