Array indexing

Elements from NumPy arrays can be selected using four methods: scalar selection, slicing, numerical indexing, and logical (or Boolean) indexing. Scalar selection and slicing are the basic methods to access elements in an array, which has already been discussed here. Numerical indexing and logical indexing are closely related and allows more flexible selection. Numerical indexing uses lists or arrays of locations to select elements, whereas logical indexing uses arrays that contain Boolean values to select elements.

Numerical indexing

Numerical indexing is an alternative to slice notation. The idea in numerical indexing is to use coordinates to select elements. This is similar to slicing. Arrays created using numerical indexing create ...

Get Mastering Python Data Visualization now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.