May 2019
Beginner
528 pages
29h 51m
English
One-dimensional arrays can be indexed and sliced using the same syntax and techniques we demonstrated in the “Sequences: Lists and Tuples” chapter. Here, we focus on array-specific indexing and slicing capabilities.
arraysTo select an element in a two-dimensional array, specify a tuple containing the element’s row and column indices in square brackets (as in snippet [4]):
In [1]: import numpy as npIn [2]: grades = np.array([[87, 96, 70], [100, 87, 90],...: [94, 77, 90], [100, 81, 82]])...:In [3]: gradesOut[3]:array([[ 87, 96, 70],[100, 87, 90],[ 94, 77, 90],[100, 81, 82]])In [4]: grades[0, 1] # row 0, column 1Out[4]: 96
array’s Rows ...Read now
Unlock full access