NumPy Boolean Array Indexing

From NovaOrdis Knowledge Base
Jump to navigation Jump to search

Internal

Overview

Boolean indexing is when a boolean array is used to select element from another array with the same shape.

If the boolean array and the target array do not have the same shape, the operation produces an IndexError:

IndexError: boolean index did not match indexed array along dimension 0; dimension is 6 but corresponding boolean dimension is 5

The boolean arrays used in boolean indexing can be generated with vectorized comparison.