Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

numpy topk

>>> a = np.array([9, 4, 4, 3, 3, 9, 0, 4, 6, 0])
array([9, 4, 4, 3, 3, 9, 0, 4, 6, 0])

>>> ind = np.argpartition(a, -4)[-4:]
array([1, 5, 8, 0])

>>> top4 = a[ind]
array([4, 9, 6, 9])
Comment

PREVIOUS NEXT
Code Example
Python :: ridge regression alpha values with cross validation score plot 
Python :: .text xpath lxml 
Python :: stripe white space django template 
Python :: python lister éléments enum 
Python :: ABA Alphabet pyramid 
Python :: Preprocessing of transfer learning inception v3 
Python :: How to make colors.winapp in WindowsAP 
Python :: iterate over k values and plot the inertia values for each k 
Python :: csv/gpd to shapefile python 
Python :: Normalize basic list data 
Python :: hashing algorithms in python 
Python :: how to print continuesly in the same line in python 
Python :: extending the existing user model 
Python :: dropdown menu with selenium python 
Python :: Filling or replacing the missing values with mode 
Python :: are you dumb python program 
Python :: Replace and count string delimiter 
Python :: python loop through specific angle 
Python :: lists as parameters in stats.f_oneway 
Python :: pandas set index integer not float 
Python :: python sum whole matrix comand 
Python :: tf.io path copy 
Python :: django test postgres extensions intarray 
Python :: how to select name parent table in model laravel 
Python :: python how to d oa hello worl 
Python :: explorer gives new window 
Python :: python selenium login button class click 
Python :: visualizzare csv in pycharm pandas read_csv 
Python :: save python dic 
Python :: create a typo with python 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =