Open workspace
Tools 1.3Code walkthrough10 parts

Indexing, Slicing and Masks

Select exactly the elements you want, including by condition.

In this lesson10 parts

  1. 01The two questions: which days beat the target, and what the chain took
  2. 02Selecting with a Python loop and an if, and what it loses
  3. 03Indexing one element: arr[i], negative positions and arr[row, col]
  4. 04Slices: arr[start:stop], the step, and a whole row or column
  5. 05A slice is a view, not a copy: shares_memory and copy
  6. 06Comparing a whole array, and the boolean array it returns
  7. 07Boolean masks: selecting, counting with sum, and assigning
  8. 08Combining conditions with &, | and ~, and why `and` fails
  9. 09Fancy indexing: a list of positions, reordered, and a copy
  10. 10Recap and your challenge