Shape, Size, and dtype
Reading the anatomy of an array.
Read the Array's Anatomy
Every array carries metadata about itself. Three labels tell you almost everything: its shape, its size, and its dtype. Let's read each one. 🔍
Shape: Rows and Columns
The shape is a tuple of dimension lengths. A 3-by-4 grid reports (3, 4): three rows down, four columns across.
a = np.zeros((3, 4))
a.shape # (3, 4)All lessons in this course
- From Python List to ndarray
- Shape, Size, and dtype
- Vectorized Math Without Loops
- Indexing and Slicing Arrays