With the help of
numpy.fill_diagonal() method, we can get filled the diagonals of numpy array with the value passed as the parameter in
Return : Return the filled value in the diagonal of an array.
Example #1 :
In this example we can see that by using
numpy.fill_diagonal() method, we are able to get the diagonals filled with the values passed as parameter.
Example #2 :
[[1 0 0]
[0 1 0]
[0 0 1]]
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.