My question may look too simple, but I am curious to know why this is available in Python.
Assume we have defined an array of size of (4,3):
import numpy as np
a=np.random.randint(15,size=(4,3))
The result would be something like below:
array([[ 7, 6, 1],
[ 5, 3, 6],
[12, 10, 11],
[ 1, 3, 4]])
What is difference between:
a[0]
Result:
array([7, 6, 1])
and
a[0:1]
Result:
array([[7, 6, 1]])
As both of them return the same part of the matrix:
7, 6, 1
I do know that the difference is the shape as the former one is (3,) and the later one is sized of (1,3). But my question is that why we need to have these kinds of shapes. If you are familiar with Matlab, giving a range using colon gives you two rows, but in Python, it returns the same information with different shape. What is the point? what is the advantage?