hstack

71

hstack() function is used to stack the sequence of input arrays
horizontally (i.e. column wise) to make a single array.
Syntax : numpy.hstack(tup) Parameters : tup : [sequence of ndarrays] Tuple
containing arrays to be stacked.
The arrays must have the same shape along all but the second axis.
>>> a = np.array((1,2,3))
>>> b = np.array((2,3,4))
>>> np.hstack((a,b))
array([1, 2, 3, 2, 3, 4])
>>> a = np.array([[1],[2],[3]])
>>> b = np.array([[2],[3],[4]])
>>> np.hstack((a,b),columns=['hurala','panalal'])
array([[1, 2],
       [2, 3],
       [3, 4]])

Comments

Submit
0 Comments