Tools 1.3Lesson outlineLesson 3 of 7 in Module 1
Indexing, Slicing and Masks
Select exactly the elements you want, including by condition.
Free sample. Everything in this module opens with a free account.Video in production.
Lesson outline: Indexing, Slicing and Masks
In this lesson10 parts
- 01The two questions: which days beat the target, and what the chain took
- 02Selecting with a Python loop and an if, and what it loses
- 03Indexing one element: arr[i], negative positions and arr[row, col]
- 04Slices: arr[start:stop], the step, and a whole row or column
- 05A slice is a view, not a copy: shares_memory and copy
- 06Comparing a whole array, and the boolean array it returns
- 07Boolean masks: selecting, counting with sum, and assigning
- 08Combining conditions with &, | and ~, and why `and` fails
- 09Fancy indexing: a list of positions, reordered, and a copy
- 10Recap and your challenge
Key terms: Indexing, Slicing and Masks
The words this lesson introduces, each in one line. The module’s glossary collects them all, and the AI glossary has every term across the courses.
- View
- An array sharing data with another array
- Copy
- An array with independent data
- Slice
- Position range with excluded stop; basic slicing generally returns a view
- Boolean mask
- Boolean array selecting elements where it is true
- Fancy indexing
- Selection by integer positions; returns a copy
Quiz: Indexing, Slicing and Masks
Your first pick on each question is the one that counts. Getting one wrong here is how the lesson sticks.