When I check the shape of an array using numpy.shape()
, I sometimes get (length,1)
and sometimes (length,)
. It looks like the differe
In Python, (length,)
is a tuple, with one 1 item. (length)
is just parenthesis around a number.
In numpy
, an array can have any number of dimensions, 0, 1, 2, etc. You are asking about the difference between 1 and 2 dimensional objects. (length,1)
is a 2 item tuple, giving you the dimensions of a 2d array.
If you are used to working with MATLAB, you might be confused by the fact that there, all arrays are 2 dimensional or larger.