Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python create a matrix with one in diagonal

# Create a matrix in python and fill
import numpy as np
a = np.zeros((3, 3), int) # Create matrix with only 0
np.fill_diagonal(a, 1) # fill diagonal with 1
print(a)
Comment

PREVIOUS NEXT
Code Example
Python :: get current directory python 
Python :: how to check python version in cmd 
Python :: encrypt and decrypt python 
Python :: np.concatenate 
Python :: seaborn heatmap text labels 
Python :: how to replace nan values with 0 in pandas 
Python :: micropython network 
Python :: dataframe to dictionary with one column as key 
Python :: CUDA error: device-side assert triggered 
Python :: get rid of n in string python 
Python :: python selenium partial class name 
Python :: play wav files python 
Python :: delete a row in pandas dataframe 
Python :: tensorflow keras save model 
Python :: get path of notebook 
Python :: read text file in python 
Python :: python datetime to timestamp 
Python :: python is integer 
Python :: python print without leading whitespace 
Python :: convert image to matrix python 
Python :: tkinter canvas remove 
Python :: save a seaborn heatmap 
Python :: python zfill 
Python :: how to set background color of an image to transparent in pygame 
Python :: reset a turtle python 
Python :: drop row based on NaN value of a column 
Python :: simple jwt django 
Python :: python exec return value 
Python :: python read requests response 
Python :: column contains substring python 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =