Array Shapes, Axes, and Broadcasting
To work effectively with NumPy operations, it’s essential to understand shapes and axes — the core concepts that define array structure.
Shape
Every array has a .shape, which shows how many elements it has in each dimension.
For example, an array with 2 rows and 3 columns has a shape of (2, 3).
Axes
An axis represents the direction along which a NumPy function performs its operation.
axis=0: down the rows (vertical)axis=1: across the columns (horizontal)
You will use axes with functions like sum(), mean(), and others.
Quiz
0 / 1
What does the shape attribute represent in NumPy?
In NumPy, the `shape` attribute shows the of an array.
data type
dimensions
values
memory size
Lecture
AI Tutor
Design
Upload
Notes
Favorites
Help