Gives a new shape to an array without changing its data.
Parameters: | a : array_like
newshape : int or tuple of ints
order : {‘C’, ‘F’}, optional
|
---|---|
Returns: | reshaped_array : ndarray
|
See also
Examples
>>> a = np.array([[1,2,3], [4,5,6]])
>>> np.reshape(a, 6)
array([1, 2, 3, 4, 5, 6])
>>> np.reshape(a, 6, order='F')
array([1, 4, 2, 5, 3, 6])
>>> np.reshape(a, (3,-1)) # the unspecified value is inferred to be 2
array([[1, 2],
[3, 4],
[5, 6]])