Starting from the second element, slice the elements from index 1 to index 4 (excluding index 4).
import numpy as np arr = np.array([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]]) print(arr[1, 1:4]) |
Note: Keep in mind that the second element has an index of 1. |
From both elements, retrieve the value at index 2.
import numpy as np arr = np.array([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]]) print(arr[0:2, 2]) |
From both elements, slice from index 1 to index 4 (excluding index 4), which will yield a 2-D array.
import numpy as np arr = np.array([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]]) print(arr[0:2, 1:4]) |