Open In App

Python | Numpy matrix.resize()

Last Updated : 18 Apr, 2019
Comments
Improve
Suggest changes
Like Article
Like
Report
With the help of Numpy matrix.resize() method, we are able to resize the shape of the given matrix. Remember all elements should be covered after resizing the given matrix.
Syntax : matrix.resize(shape) Return: new resized matrix
Example #1 : In the given example we are able to resize the given matrix by using matrix.resize() method. Python3 1=1
# import the important module in python
import numpy as np
         
# make matrix with numpy
gfg = np.matrix('[64, 1; 12, 3]')
         
# applying matrix.resize() method
geeks = gfg.resize((1, 4))
   
print(geeks)
Output:
[[64  1 12  3]]
Example #2 : Python3 1=1
# import the important module in python
import numpy as np
         
# make a matrix with numpy
gfg = np.matrix('[1, 2; 4, 5; 7, 8]')
         
# applying matrix.resize() method
geeks = gfg.resize((2, 3))
   
print(geeks)
Output:
[[1 2 4]
 [5 7 8]]

Next Article
Practice Tags :

Similar Reads

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy