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 new array is filled with repeated copies of a
. Note that this behavior is different from a.resize(new_shape) which fills with zeros instead of repeated copies of a
.
Parameters: |
|
---|---|
Returns: |
|
See also
ndarray.resize
Warning: This functionality does not consider axes separately, i.e. it does not apply interpolation/extrapolation. It fills the return array with the required number of elements, taken from a
as they are laid out in memory, disregarding strides and axes. (This is in case the new shape is smaller. For larger, see above.) This functionality is therefore not suitable to resize images, or data where each axis represents a separate and distinct entity.
>>> 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]])
© 2005–2019 NumPy Developers
Licensed under the 3-clause BSD License.
https://docs.scipy.org/doc/numpy-1.17.0/reference/generated/numpy.resize.html