Sahaj.blogs

Day page

12 Feb 2024

Study

NumPy · Boolean and fancy indexing

Selecting with boolean masks and integer arrays, combining conditions with & and |, np.where, and why these return copies.

  • A comparison like a > 5 gives a boolean mask, and a[mask] selects the matching elements.
  • Use & and
  • with parentheses, not and/or, to combine element-wise conditions.

Read the post →