1>>> np.reshape(a, (2, 3)) # C-like index ordering
2array([[0, 1, 2],
3 [3, 4, 5]])
4>>> np.reshape(np.ravel(a), (2, 3)) # equivalent to C ravel then C reshape
5array([[0, 1, 2],
6 [3, 4, 5]])
7>>> np.reshape(a, (2, 3), order='F') # Fortran-like index ordering
8array([[0, 4, 3],
9 [2, 1, 5]])
10>>> np.reshape(np.ravel(a, order='F'), (2, 3), order='F')
11array([[0, 4, 3],
12 [2, 1, 5]])
13
1np.reshape(a, (2, 3)) # C-like index ordering
2array([[0, 1, 2],
3 [3, 4, 5]])
4np.reshape(np.ravel(a), (2, 3)) # equivalent to C ravel then C reshape
5array([[0, 1, 2],
6 [3, 4, 5]])
7np.reshape(a, (2, 3), order='F') # Fortran-like index ordering
8array([[0, 4, 3],
9 [2, 1, 5]])
10np.reshape(np.ravel(a, order='F'), (2, 3), order='F')
11array([[0, 4, 3],
12 [2, 1, 5]])
1>>> np.reshape(a, (3,-1)) # the unspecified value is inferred to be 2
2array([[1, 2],
3 [3, 4],
4 [5, 6]])
5
1>>> a = np.arange(6).reshape((3, 2))
2>>> a
3array([[0, 1],
4 [2, 3],
5 [4, 5]])
6