Python | Numpy matrix.fill()
Last Updated :
12 Apr, 2019
With the help of Numpy matrix.fill()
method, we are able to fill a scalar value
in a given matrix and gives output as matrix having scalar values.
Syntax : matrix.fill(value)
Return : Return a matrix having scalar value
Example #1 :
In this example we can see that with the help of matrix.fill()
method we are able to fill the given matrix with a scalar value.
import numpy as np
gfg = np.matrix( '[6, 2, 3]' )
gfg.fill( 0 )
print (gfg)
|
Example #2 :
import numpy as np
gfg = np.matrix( '[1, 2, 3; 4, 5, 6]' )
gfg.fill( 1 )
print (gfg)
|
Output:
[[1 1 1]
[1 1 1]]
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...