Data Tools · Module 1

NumPy7 lessons and their Study toolkit.

Watch each lesson, answer its quiz, then do its practice. After the last lesson: the module quiz, the project, and the interview questions.

7of 7 lessons ready
50quiz questions
25key terms
5self-checking notebooks

The lessonsin the order to take them.

7 lessons ready to study
  1. 1.1Why NumPySay what an array holds that a list does not, and why that makes it faster and smaller. Open
  2. 1.2Shape, dtype and ReshapingRead any array's shape and dtype, and reshape without copying. Open
  3. 1.3Indexing, Slicing and MasksSelect exactly the elements you want, including by condition. Open
  4. 1.4Vectorised Operations and BroadcastingCompute on whole arrays at once, and predict when shapes combine. Open
  5. 1.5Aggregations Along AxesSum, average and find extremes over rows or columns. Open
  6. 1.6Linear Algebra in NumPyWrite the maths of the ML videos directly as code. Open
  7. 1.7Random Numbers and ReproducibilityGenerate random data you can reproduce. Open

Glossaryevery term the module introduces.

Each with the lesson that introduces it.

Array
Values in a typed buffer, interpreted through a shape 1.1
Buffer
Contiguous storage for the array's elements 1.1
Object dtype
References to Python objects instead of fixed-width numeric values 1.1
Shape
Element count on each axis, as a tuple 1.2
Dimension / ndim
An axis / the number of axes 1.2
dtype
The type and width used for array elements 1.2
Reshape
Interpret the same number of elements with a new shape; a copy is possible for non-contiguous inputs 1.2
View
An array sharing data with another array 1.3
Copy
An array with independent data 1.3
Slice
Position range with excluded stop; basic slicing generally returns a view 1.3
Boolean mask
Boolean array selecting elements where it is true 1.3
Fancy indexing
Selection by integer positions; returns a copy 1.3
Vectorisation
Applying an operation to an entire array instead of a Python loop over its elements 1.4
Universal function
NumPy function applying an operation elementwise 1.4
Broadcasting
Matching dimensions from the right, repeating a size-one dimension conceptually 1.4
Axis
Dimension named by an operation; reduction removes that dimension 1.5
Reduction
Combining values along an axis, such as sum or mean 1.5
keepdims
Retain a reduced axis with size one 1.5
argmax
Position of the maximum, not the maximum value 1.5
Transpose
Exchange axes of a two-dimensional array 1.6
Matrix product
Row-column combination written @ 1.6
Linear system
Equations represented as A @ w = b 1.6
Generator
Object with its own random state and sampling methods 1.7
Seed
Starting value used to reproduce a generator's sequence 1.7
Permutation
Reordering of positions without duplication 1.7

Module quiz15 questions across it all.

Take it after the last lesson. Your first pick on each question is the one that counts.

Project: The chain's year, in NumPybuild it without a template.

Stated as a problem, with no step-by-step instructions. Working out the steps is the point.

The task

Write one Colab notebook that loads sales.csv and produces a summary of the chain's year, using NumPy only — no loops over the data, except where you are explicitly comparing a loop against an array.

It must report:

  1. the grid's shape, dtype and nbytes, and the narrowest dtype that holds the units column without wrapping;
  2. the chain's total for the year, and each shop's total;
  3. how many days each shop beat its own target;
  4. which shop led the chain on each day, and how many days each shop led;
  5. each shop's revenue standardised against its own mean and spread, and the single best day in the chain on that standardised scale — with the date and the shop;
  6. the weights that make footfall, promotion and temperature predict revenue, solved from the normal equations;
  7. a ten row random sample of shop-days that anyone re-running your notebook gets identically.

Notebooksthat check your answers.

Open them in Google Colab. Each answer is checked as you go: correct, wrong with the expected value, or not answered yet.

  • Arrays and shapeLessons 1.1 and 1.2 Courses plan
  • Selection and broadcastingLessons 1.3 and 1.4 Courses plan
  • Axes and linear algebraLessons 1.5 and 1.6 Courses plan
  • Random numbers and reproducibilityLessons 1.7 Courses plan
  • The chain's yearThe module project, with checks Courses plan

Common mistakesacross the whole module.

What you see when it goes wrong, why it happens, and the fix.

Referencefor revising and for interviews.

The cheat sheet is one page of the module’s terms, rules and gotchas. The interview questions come with model answers.