Indexing & Slicing
Picking out elements, rows, columns, and matches to a condition.
For a 2-D array, index with array[row, col]: a single comma-separated
tuple, not array[row][col] chained twice (that works too, but it's slower
since it builds an intermediate array).
(also called masking) is the
pattern you'll use constantly: comparing an array gives you an array of
True/False, and indexing with that mask keeps only the matching elements.
⚠️ Watch out: Slices (a[1:3]) share memory with the original array; modifying a slice modifies the source. Boolean/fancy indexing (a[mask], a[[0,2]]) always makes a copy.
Now practice it
Exercises that use what this lesson just covered.