Movatterモバイル変換


[0]ホーム

URL:


SciPy

numpy.resize

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

Array to be resized.

new_shape : int or tuple of int

Shape of resized array.

Returns:

reshaped_array : ndarray

The new array is formed from the data in the old array, repeatedif necessary to fill out the required number of elements. Thedata are repeated in the order that they are stored in memory.

See also

ndarray.resize
resize an array in-place.

Examples

>>>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]])

Previous topic

numpy.append

Next topic

numpy.trim_zeros

  • © Copyright 2008-2009, The Scipy community.
  • Last updated on Jun 10, 2017.
  • Created usingSphinx 1.5.3.

[8]ページ先頭

©2009-2025 Movatter.jp