Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

numpy retrieve 5 highest value index

array = np.array([9, 4, 4, 3, 3, 9, 0, 4, 6, 0])
# n highest value
n = 5
# Index of n highest value
ind = np.argpartition(a, -n)[-n:]
ind
array([1, 5, 8, 0])
# n highest value
top4 = a[ind]
top4
array([4, 9, 6, 9])
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #numpy #retrieve #highest #index
ADD COMMENT
Topic
Name
6+8 =