Indexing: A few handy ways to access NumPy arrays
The following code snippets should serve as an (incomplete) cheat sheet for accessing NumPy arrays. All examples expect an import numpy as np. Basic access NumPy arrays can be accessed just like lists with array[start:stop:step] a = np.array([1,2,3,4], int) # => array([1, 2, 3, 4]) a[2] # => 3 a[:2] # => array([1, 2]) a[::2] # => array([1, 3]) When working with multidimensional arrays, a comma can be used to access values for the different axes: ...