Python | Numpy matrix.view ()

NumPy | Python Methods and Functions

Using the Numpy matrix.view () method, we can find a new kind of matrix using the matrix.view () method.

Syntax: matrix.view ()
Return: Return new view for same matrix

Example # 1:
In this example we can see that using matrix.view ( ) we can find a new kind of this matrix.

# import important module into python

import numpy as np

 
# make a matrix with NumPy

gfg = np.matrix ( `[4, 1; 12, 3]` )

 
# applying the matrix.view method ()

geek = gfg.view ()

 

print (geek)

Output:

 [[4 1] [12 3]] 

Example # 2:

# import an important module into python

import numpy as np

 
# make a matrix with NumPy

gfg = np.matrix ( `[4, 1, 9 ; 12, 3, 1; 4, 5, 6] ` )

  
# applying the matrix.view () method

geek = gfg.view ()

 

print (geek)

Exit:

 [[4 1 9] [12 3 1] [4 5 6]] 




Get Solution for free from DataCamp guru