Python | Numpy matrix.getfield ()



Using the Numpy matrix.getfield () method, we can get the matrix of the field, which means that the field is a matrix of the given type data the same size as our matrix.

Syntax: matrix.getfield()

Return: Return field matrix

Example # 1:
In this example, we see that we can get the matrix of the field using the matrix.getfield () method.

# import important module into python

import numpy as np

 
# make a matrix with NumPy

gfg = np.mat rix ( `[6, 1; 2, 3] ` )

  
# using the matrix.getfield () method

geeks = gfg.getfield ( int )

 

print (geeks)

Exit:

 [[6 1] [2 3]]  

Example # 2:

# import important module into python

import numpy as np

 
# make a matrix with NumPy

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

  
# using the matrix.getfield () method

geeks = gfg.getfield ( int )

 

print (geeks)

Exit:

 [[1 2 3] [4 5 6] [7 8 9]]