Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

numpy diag()

>>> x = np.arange(9).reshape((3,3))
>>> x
array([[0, 1, 2],
       [3, 4, 5],
       [6, 7, 8]])

>>> np.diag(x)
array([0, 4, 8])
>>> np.diag(x, k=1)
array([1, 5])
>>> np.diag(x, k=-1)
array([3, 7])
Comment

PREVIOUS NEXT
Code Example
Python :: python code for internet radio stream 
Python :: Python NumPy append Function Example Appending arrays 
Python :: app.py 
Python :: python loop to a tuple 
Python :: python function create null matrix 
Python :: dependency injection python 
Python :: division of 2 numbers in python 
Python :: topological sort 
Python :: alphabet 
Python :: python TypeError: function takes positional arguments but were given 
Python :: search and replace in python 
Python :: select each two elements on a list python 
Python :: python find closest date 
Python :: python responses 
Python :: __str__ returned non-string (type User) 
Python :: python capture stdout 
Python :: lower method in python 
Python :: convolution operation pytorch 
Python :: how to split a string by space in python 
Python :: python tkinter focus on entry 
Python :: how to normalize scipy cross correlation 
Python :: comments in python 
Python :: 3d data visualization python 
Python :: python remove the element in list 
Python :: private key 
Python :: Use operator in python list 
Python :: reading from a text file 
Python :: python rounding numbers to n digits 
Python :: how to use the sleep function in python 
Python :: pdf to word 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =