The codes are like this:
a = numpy.zeros(3)
b = numpy.ones(3)
bind_by_column((a,b))
=> [[0,1],[0,1],[0,1]]
I checked this but don't find the answer
Does anyone have ideas about this?
In order to join NumPy arrays column-wise, we can also use the concatenate() function. In this case, however, we would use the axis=1 parameter, in order to specify that we want to join the arrays along the column axis.
Use a[:,1] = x[:,0] . You need x[:,0] to select the column of x as a single numpy array.
all() in Python. The numpy. all() function tests whether all array elements along the mentioned axis evaluate to True.
np.column_stack
see 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.]])
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.]])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With