← all tracks

NumPy

Arrays, shapes and broadcasting — the layer everything else is built on.

28 of 28 lessons built·0 of 104 exercises solved
Module 1

Foundations

4/4

What an array is made of, and how it sits in memory.

  1. 1

    What an ndarray actually is

    One type, one block of memory — and why everything else follows from that.

  2. 2

    Making arrays

    zeros, ones, arange, linspace, eye, random — pick a shape, then a filling rule.

  3. 3

    dtypes, precision and casting

    Fixed-width boxes — and every surprise that follows from them.

  4. 4

    Memory, strides and contiguity

    One number per axis that explains reshape, transpose and every free operation.

Module 2

Indexing & selection

5/5

Getting at the values you want — by position, by condition, by list.

  1. 5

    Indexing and slicing

    One range per axis — and why an integer removes an axis while a slice keeps it.

  2. 6

    Views, copies and shared memory

    Slicing doesn’t copy — and that will edit your data behind your back exactly once.

  3. 7

    Boolean masks

    Selecting by condition — and why the answer comes back flat.

  4. 8

    Fancy indexing

    Indexing with a list of positions — and why two lists zip instead of crossing.

  5. 9

    where, select and clip

    An if-statement over a whole array, without losing its shape.

Module 3

Shape

4/4

Rearranging, joining, splitting, and making mismatched shapes agree.

  1. 10

    Reshaping and transposing

    The memory never moves — only the rule for walking it.

  2. 11

    Adding, removing and moving axes

    newaxis, squeeze, moveaxis — the tools for making shapes line up.

  3. 12

    Joining and splitting arrays

    concatenate extends an axis; stack creates one. Everything else is shorthand.

  4. 13

    Broadcasting

    How NumPy makes mismatched shapes work — without copying anything.

Module 4

Computation

5/5

Doing arithmetic to whole arrays, then reducing them down.

  1. 14

    Vectorisation and ufuncs

    The loop doesn’t disappear — it moves somewhere much faster.

  2. 15

    Aggregation and the axis argument

    The axis you name is the axis that disappears.

  3. 16

    Running totals and differences

    The reductions that don’t reduce — cumsum, diff, and their friends.

  4. 17

    Sorting and searching

    argsort is the one that matters — it returns the order, so you can apply it anywhere.

  5. 18

    unique and set operations

    Distinct values, frequency tables, and the vectorised version of `in`.

Module 5

Numerics

4/4

Missing values, randomness, statistics and linear algebra.

  1. 19

    NaN, inf and missing values

    Why one gap poisons a whole sum, and why `== np.nan` never finds anything.

  2. 20

    Random numbers and sampling

    Seed it, or you can’t tell a real change from noise.

  3. 21

    Summary statistics

    mean vs median, spread, percentiles — and when the average lies to you.

  4. 22

    Linear algebra

    @ is not *, and that one character is most of machine learning.

Module 6

In practice

3/3

Coordinate grids, making it fast, and getting data in and out.

  1. 23

    Coordinate grids

    meshgrid, mgrid, ogrid — how you compute a function of position without a loop.

  2. 24

    Making it fast

    Kill the loops, stop copying, reuse buffers — in that order.

  3. 25

    Saving and loading

    Binary keeps everything; text loses your dtypes. Know which you want.

Module 7

Capstones

3/3

Whole projects that use the lot.

  1. 26

    Capstone: edit a photo with nothing but NumPy

    capstone

    Every idea from the track, applied to something you can see.

  2. 27

    Capstone: analysis without pandas

    capstone

    Inspect, clean, aggregate, rank — 270 readings and no DataFrame in sight.

  3. 28

    Capstone: Conway’s Game of Life, without a single loop

    capstone

    A whole simulation in two lines of array arithmetic.