np subarray code example
Example 1: taking subarray of numpy array
>>> a
array([[1, 2, 3],
[4, 5, 6],
[7, 8, 9]])
>>> a[:2,:2]
array([[1, 2],
[4, 5]])
Example 2: numpy subarray
>>> a
array([[1, 2, 3],
[4, 5, 6],
[7, 8, 9]])
>>> a[:2,:2]
array([[1, 2],
[4, 5]])