Broadcasting
Unit ID: M08-U06 Estimated active time: 25-35 minutes
Broadcasting lets NumPy combine compatible shapes without manually copying values.
weekly_adjustment = np.array([0, 5, 0, -5])
adjusted = study_minutes + weekly_adjustment
The adjustment has shape (4,), matching the four columns, so it is applied to each row. A column adjustment can use shape (6, 1) for six learners.
Shapes are compared from the right. Dimensions are compatible when they match or one of them is 1.
An array with shape (6, 4) cannot directly combine with (6,) because the rightmost dimensions are 4 and 6. Reshape the learner values to (6, 1) when that meaning is intended.
Practice: predict whether (6, 4) combines with (4,), (6, 1), (1, 4), and (3,). Explain the intended meaning, not only the rule.
