NumPy offers a helper function called hstack()
for stacking arrays along rows.
import numpy as np arr1 = np.array([1, 2, 3]) arr2 = np.array([4, 5, 6]) arr = np.hstack((arr1, arr2)) print(arr) |
NumPy provides the vstack() helper function to stack arrays along columns.
import numpy as np arr1 = np.array([1, 2, 3]) arr2 = np.array([4, 5, 6]) arr = np.vstack((arr1, arr2)) print(arr) |
NumPy offers the dstack() helper function to stack arrays along the height, also referred to as the depth.
import numpy as np arr1 = np.array([1, 2, 3]) arr2 = np.array([4, 5, 6]) arr = np.dstack((arr1, arr2)) print(arr) |