shape in np code example
Example 1: numpy shape
>>> a = np.array([(1, 2), (3, 4)], dtype=[('x', 'i4'), ('y', 'i4')])
>>> np.shape(a)
(2,)
>>> a.shape
(2,)
Example 2: convert np shape (a,) to (a,1)
# numpy array/vector (n,) dimension -> (n,1) dimension conversion
a = np.arange(3) # a.shape = (3,)
b = a.reshape((3,1)) # b.shape = (3,1)
c = b.reshape((3,)) # c.shape = (3,)
c2 = b.reshape((-1,1)) # c2.shape = (3,)