Example 1: reshape python
>>> np.reshape(a, (2, 3))
array([[0, 1, 2],
[3, 4, 5]])
>>> np.reshape(np.ravel(a), (2, 3))
array([[0, 1, 2],
[3, 4, 5]])
>>> np.reshape(a, (2, 3), order='F')
array([[0, 4, 3],
[2, 1, 5]])
>>> np.reshape(np.ravel(a, order='F'), (2, 3), order='F')
array([[0, 4, 3],
[2, 1, 5]])
Example 2: numpy reshape
np.reshape(a, (2, 3))
array([[0, 1, 2],
[3, 4, 5]])
np.reshape(np.ravel(a), (2, 3))
array([[0, 1, 2],
[3, 4, 5]])
np.reshape(a, (2, 3), order='F')
array([[0, 4, 3],
[2, 1, 5]])
np.reshape(np.ravel(a, order='F'), (2, 3), order='F')
array([[0, 4, 3],
[2, 1, 5]])
Example 3: reshape (n ) to (n 1)
'''
This code is contributed by :
Tanishq Vyas (github : https://github.com/tanishqvyas )
'''
actual = actual.reshape((actual.shape[0], 1))
Example 4: convert np shape (a,) to (a,1)
a = np.arange(3)
b = a.reshape((3,1))
c = b.reshape((3,))
c2 = b.reshape((-1,1))