Broadcasting lets NumPy operate on arrays with different shapes without manually copying the smaller one. Compatibility is checked from the trailing dimensions: each pair must match or one dimension must equal 1.

import numpy as np

vendas = np.array([
    [100.0, 80.0, 120.0],
    [90.0, 110.0, 70.0],
])
fatores = np.array([1.0, 0.9, 1.1])

ajustadas = vendas * fatores
print(ajustadas.shape)  # (2, 3)

The three-element factor vector applies to every row of the (2, 3) matrix. Document or assert shapes in critical calculations because a compatible shape can still produce a semantically wrong result without raising an exception.

Practical guidance

Use reshape, None, or np.newaxis to make an axis explicit. Inspect array.shape and test with small values whose output can be calculated by hand. Avoid tile() merely to imitate broadcasting because it often allocates unnecessary copies.

Read the complete NumPy guide and use scikit-learn pipelines for consistent machine-learning transformations.

The official NumPy broadcasting guide, accessed July 22, 2026, documents the API and its constraints.