>>> a
array([1, 2, 3, 4])
>>> a.ndim
1
>>> b = np.array([[1,2,3,4],[5,6,7,8],[9,10,11,12]])
>>> b.ndim
2
If you wanted a column vector, you can use the .reshape
method - in fact, .shape
is actually a settable property so numpy also lets you do this:
>>> a
array([1, 2, 3, 4])
>>> a.shape += (1,)
>>> a
array([[1],
[2],
[3],
[4]])
>>> a.shape
(4, 1)
>>> a.ndim
2