The following:
arr2d = np.array([[5,10,15],[15,20,25],[30,35,40]])
arr2d[:2,1:]
Produces:
array([[10, 15],
[20, 25]])
I would like to know how the result is calculated.
The following:
arr2d = np.array([[5,10,15],[15,20,25],[30,35,40]])
arr2d[:2,1:]
Produces:
array([[10, 15],
[20, 25]])
I would like to know how the result is calculated.
I think you want to read about Numpy indexing
In [54]: arr2d[:2,1:]
Out[54]:
array([[10, 15],
[20, 25]])
means - give me first two rows and all columns starting from the second one (1)
In [56]: arr2d[:2,:]
Out[56]:
array([[ 5, 10, 15],
[15, 20, 25]])
In [57]: arr2d[:2,1:]
Out[57]:
array([[10, 15],
[20, 25]])
arr2d[:2,1:]
means "rows up to (but not including!) 2, columns 1 to last".