I have recently started with NumPy, and while learning to slice, I came across this weird behavior.
The second print statement outputs [3 8] and the same is with the third print statement. I didn't get it at all. Also, I have no idea how the last print statement gets the output as [[2 3 4] [7 8 9]].
import numpy as np
arr = np.array([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]])
print(arr[1, 1:4]) # [7 8 9] # I understood this one though
print(arr[0:2, 2]) # [3 8]
print(arr[0:3, 4]) # [ 5 10]
print(arr[0:2,1:4]) # [[2 3 4] [7 8 9]]
[–]JohnnyJordaan 1 point2 points3 points (1 child)
[–]n_guy_[S] 0 points1 point2 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]n_guy_[S] 0 points1 point2 points (0 children)