Python | Numpy matrix.round ()



Using the Numpy matrix.round () method, we can round the values ​​of a given matrix.

Syntax: matrix.round()

Return: Return rounded values ​​in matrix

Example # 1:

In this example, we can round this matrix using matrix.round () .

# import an important module into python

import numpy as np

 
# make a matrix with NumPy

gfg = np.matrix ( `[6.4, 1.3; 12.7, 32.3]` )

  
# using the matrix.round () method

geeks = gfg. round ()

 

print (geeks)

Output:

 [[6. 1.] [13. 32.]] 

Example # 2:

# import an important module into python

import numpy as np

 
# make a matrix with NumPy

gfg = np.matrix ( `[1.2, 2.3; 4.7, 5.5; 7.2, 8.9] ` )

  
# applying the matrix.round () method

geeks = gfg. round ()

 

print (geeks)

Exit:

 [[1. 2.] [5. 6. ] [7. 9.]]