NumPy, by Running It

Arrays instead of loops - the shapes, the broadcasting rules, and the views that catch everyone, each one runnable on the page.

20 modules Free, no login Updated 31 August 2026

About this track

A Python list holds pointers to objects scattered across memory. A NumPy array holds numbers, of one type, laid out end to end. Almost everything that makes NumPy fast, and everything that makes it surprising, follows from that one difference.

This track works up from creating an array to broadcasting, views, aggregation along an axis, and the linear algebra underneath every machine learning library. Every idea arrives as a small program you can run and edit here, because the fastest way to settle what a shape will do is to print it.

Every example runs in the browser against the real library, and several are written so the output contradicts the guess most people would make - that a slice is a copy, or that axis=0 means along the rows. Being wrong on the page and seeing it immediately is the point.

What you will be able to do

How the track is ordered

Arrays come first, because the dtype and the shape decide almost everything that follows. Then indexing and slicing, which is where views appear, and vectorised arithmetic, which is the reason to use the library at all. Broadcasting, masking and fancy indexing build on those three. Aggregation along an axis comes next, then the structural operations - stacking, transposing, sorting - and finally the linear algebra that sits under every machine learning library, plus the performance and file-format material you need once the arrays get large.

Where this leads

NumPy is the layer under pandas, scikit-learn, PyTorch and matplotlib, so the shapes and dtypes here reappear in all of them. The pandas track adds labels and mixed types to the same arrays; the matplotlib track draws them.

All 20 modules, in teaching order

  1. 01What NumPy Is For
  2. 02Creating Arrays
  3. 03Dtypes
  4. 04Shape and Reshape
  5. 05Indexing and Slicing
  6. 06Vectorised Arithmetic
  7. 07Broadcasting
  8. 08Boolean Masking
  9. 09Fancy Indexing
  10. 10Aggregations and axis
  11. 11Views versus Copies
  12. 12Stacking and Splitting
  13. 13Transpose and Moving Axes
  14. 14Sorting and Searching
  15. 15Unique Values and Set Operations
  16. 16Random Numbers
  17. 17Linear Algebra
  18. 18NaN and Missing Data
  19. 19Performance and Memory
  20. 20Saving and Loading Arrays

Other tracks