numpy.resize(a,new_shape)[source]¶Return a new array with the specified shape.
If the new array is larger than the original array, then the newarray is filled with repeated copies ofa. Note that this behavioris different from a.resize(new_shape) which fills with zeros insteadof repeated copies ofa.
| Parameters: | a : array_like
new_shape : int or tuple of int
|
|---|---|
| Returns: | reshaped_array : ndarray
|
See also
ndarray.resizeExamples
>>>a=np.array([[0,1],[2,3]])>>>np.resize(a,(2,3))array([[0, 1, 2], [3, 0, 1]])>>>np.resize(a,(1,4))array([[0, 1, 2, 3]])>>>np.resize(a,(2,4))array([[0, 1, 2, 3], [0, 1, 2, 3]])