vstack in numpy code example

Example 1: np vstack

>>> a = np.array([1, 2, 3])
>>> b = np.array([2, 3, 4])
>>> np.vstack((a,b))
array([[1, 2, 3],
       [2, 3, 4]])
       
>>> a = np.array([[1], [2], [3]])
>>> b = np.array([[2], [3], [4]])
>>> np.vstack((a,b))
array([[1],
       [2],
       [3],
       [2],
       [3],
       [4]])

Example 2: python numpy vstack

>>> a = np.array([1, 2, 3])
>>> b = np.array([2, 3, 4])
>>> np.vstack((a,b))
array([[1, 2, 3],
       [2, 3, 4]])

Example 3: numpy stack arrays vertically

import numpy as np
# ensure same shape of arrays to be stacked.
a = np.arange(10).reshape(2,-1)
b = np.repeat(1, 10).reshape(2,-1)
# use vstack() to stack by row.
out = np.vstack((a,b))
## print output
print(out)
# a
# b