Advanced indexing
Let's now discuss more advanced indexing techniques. We can index ndarray
objects using other ndarray
. We can slice an ndarray
using either ndarray
objects containing integers that correspond to the indices of the ndarray
we wish to select, or ndarray
objects of Boolean values, where the value true
means a cell should be included in the slice.
Select the elements of arr2
that are not Wayne
, and this is the result:
Wayne is not included in the selection, and this was the array that was generated to do that indexing:
It is True
everywhere except where the contents were Wayne
.
Another more advanced technique is to select using arrays of integers that identify which elements we want. So here, we're going to create two arrays that will be used for this slicing:
This first 0 in the first array means the first coordinate is zero, and the first 0 in the second array means that second coordinate is zero, as specified by the order these two arrays are listed in. So, in the first row and...