📜  numpy.ndarray.resize()函数– Python

📅  最后修改于: 2022-05-13 01:54:49.605000             🧑  作者: Mango

numpy.ndarray.resize()函数– Python

numpy.ndarray.resize()函数就地改变数组的形状和大小。

代码#1:

# Python program explaining
# numpy.ndarray.resize() function
        
# importing numpy as geek 
import numpy as geek 
    
arr = geek.array([[0, 1], [2, 3]])
  
# this function change the shape and size
# of the array & return None
gfg = arr.resize((2, 1))
  
print (gfg)

输出 :

None


代码#2:

# Python program explaining
# numpy.ndarray.resize() function
        
# importing numpy as geek 
import numpy as geek 
    
arr = geek.array([[0, 1], [2, 3]], order = 'F')
  
# this function change the shape and size
# of the array & return None
gfg = arr.resize((2, 1))
   
print (gfg)

输出 :

None