Curriculum
Course: NumPy
Login

Curriculum

NumPy

Text lesson

Stacking Along Rows

NumPy offers a helper function called hstack() for stacking arrays along rows.

Example

import numpy as np

arr1 = np.array([123])

arr2 = np.array([456])

arr = np.hstack((arr1, arr2))

print(arr)

Stacking Along Columns

NumPy provides the vstack() helper function to stack arrays along columns.

Example

import numpy as np

arr1 = np.array([123])

arr2 = np.array([456])

arr = np.vstack((arr1, arr2))

print(arr)

Stacking Along Height (depth)

NumPy offers the dstack() helper function to stack arrays along the height, also referred to as the depth.

Example

import numpy as np

arr1 = np.array([123])

arr2 = np.array([456])

arr = np.dstack((arr1, arr2))

print(arr)