Stage 1 · Lesson 3 of 8
NumPy arrays, shapes and indexing
A is a grid of numbers that all share one type, stored side by side in memory so the computer can process them quickly. Its shape tells you its size: (1000, 3) means 1,000 rows and 3 columns. Almost every ML library, from pandas to to , passes data around as arrays, so learn to read shapes fluently.
Practise creating arrays with np.array, np.zeros and np.arange. Check .shape, and .dtype for the number type. Slice out a column with a[:, 0], keep only matching values with a like a[a > 0], and change the layout with reshape.
Common trapmixing up a 1D array of shape (3,) with a 2D array of shape (3, 1) or (1, 3). They print alike but combine very differently, and shape bugs are the most common bug you will meet in the rest of this roadmap.
A question to check yourself, an AI practice session and 1 cheat sheet entry come with the full roadmap. Unlock
Resources for this stage
Start with· follow one of these
- CoursePaidGrokking Python Fundamentals
Design Gurus · Beginner · $50
Core Python with an exercise after nearly every lesson, before the data libraries
- BookFreePython for Data Analysis, 3rd Edition
Wes McKinney · Beginner
Free online: NumPy, pandas and plotting from pandas' own creator