Which One Is Which Between Column Slicing And Row Slicing?
Scipy has different kind of matrices. Two of them are the column sparse matrix and the row sparse matrix. The column sparse matrix supports fast column slicing operations and the
Solution 1:
There is nothing like trying it by yourself:
In [1]: import numpy as np
In [2]: np.arange(9).reshape(3,3)
Out[2]:
array([[0, 1, 2],
[3, 4, 5],
[6, 7, 8]])
In [3]: a = np.arange(9).reshape(3,3)
In [4]: a[0, :]
Out[4]: array([0, 1, 2])
In [5]: a[:, 0]
Out[5]: array([0, 3, 6])
Ergo, the first index corresponds to the row and the second to the column. a[i, :]
is selecting the row i
, so it is a row slicing operation.
Post a Comment for "Which One Is Which Between Column Slicing And Row Slicing?"