Horje
get n largest values from 2D numpy array matrix Code Example
get n largest values from 2D numpy array matrix
""" for this matrix:
[[ 8,  9,  4],
 [10,  5, 18],
 [ 5,  6,  6]]
"""
n = 5
rows = mat4.shape[0]
row_col_idxs = [(e//rows, e-(e//rows * rows)) 
				for e in mat4.flatten().argsort()[::-1][:n]]
""" result: [(1, 2), (1, 0), (0, 1), (0, 0), (2, 2)] """




Python

Related
run all jupyter notebooks in project folder Code Example run all jupyter notebooks in project folder Code Example
download youtube audio python Code Example download youtube audio python Code Example
custom save django Code Example custom save django Code Example
convert decimal to float in python Code Example convert decimal to float in python Code Example
python % meaning Code Example python % meaning Code Example

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