Which number represents rows and columns in the tuple returned by shape?
rows
, columns
are just the names we give, by convention, to the 2 dimensions of a matrix
(or more generally a 2d numpy array).
np.matrix
is, by definition, 2d, so this convention is useful. But np.array
may have 0, 1, 2 or more dimensions. For that these 2 names are less useful. For example if 1d, does it have rows or columns? If 3d, what do we call the last dimension, depth? or maybe the first is pages?
So don't put too much emphasis on the names. Most numpy
functions ask you to specify the 'axis', by number, 0, 1, 2 etc., not by name.
There may be further confusion if you load data from a csv file, and get a 1d array (one 'row' per line of the file) of dtype fields. Are fields the same as columns? Sort of, but not quite.
The matrix in question has 2 rows and 3 columns (it is of dimension 2x3), where each of the matrix elements is of value zero.
A.shape
will return a tuple (m, n), where m is the number of rows, and n is the number of columns.