numpy.ndarray.resize() function – Python
numpy.ndarray.resize() function change shape and size of array in-place.
Syntax : numpy.ndarray.resize(new_shape, refcheck = True)
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course
Parameters :
new_shape :[tuple of ints, or n ints] Shape of resized array.
refcheck :[bool, optional] If False, reference count will not be checked. Default is True.Return : None
Code #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 Nonegfg = arr.resize((2, 1)) print (gfg) |
Output :
None
Code #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 Nonegfg = arr.resize((2, 1)) print (gfg) |
Output :
None


