Horje
converting 1d array into upper triangular Code Example
converting 1d array into upper triangular
In [680]: ind = np.triu_indices(4)
In [681]: values = np.arange(16).reshape(4,4)[ind]
In [682]: result = np.zeros((4,4),int)
In [683]: result[ind]=values
In [684]: values
Out[684]: array([ 0,  1,  2,  3,  5,  6,  7, 10, 11, 15])
In [685]: result
Out[685]: 
array([[ 0,  1,  2,  3],
       [ 0,  5,  6,  7],
       [ 0,  0, 10, 11],
       [ 0,  0,  0, 15]])




Python

Related
truthy falsy python Code Example truthy falsy python Code Example
python while loop Code Example python while loop Code Example
python selenium not returning correct source Code Example python selenium not returning correct source Code Example
for loop inclusive python Code Example for loop inclusive python Code Example
django import excel file from same directory Code Example django import excel file from same directory Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
6