Lecture
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.
Lessons in this chapter · NumPy Essentials for Data Analysis
- 1. What is NumPy and Why Use It?
- 2. Creating 1D and 2D Arrays
- 3. Indexing and Slicing Arrays
- 4. Array Arithmetic and Broadcasting
- 5. Boolean Masking and Filtering
- 6. Array Shapes, Axes, and Broadcasts
- 7. Multiple-choice quiz
- 8. Aggregation Functions (sum, mean, std, etc.)
- 9. Array Reshaping and Flattening
- 10. Generating Arrays (arange, linspace, zeros, ones)
- 11. Data Type Conversion and Copying Arrays
- 12. Working with Multidimensional Arrays
- 13. Fill-in-the-blank quiz
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