Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

.argsort() python

x = np.array([[0,3],[2,2]])

>>> ind = np.argsort(x, axis=1)  # sorts along last axis (across)
>>> ind
array([[0, 1],
       [0, 1]])
>>> np.take_along_axis(x, ind, axis=1)  # same as np.sort(x, axis=1)
array([[0, 3],
       [2, 2]])
Comment

python argsort

>>> x = np.array([3, 1, 2])
>>> np.argsort(x)
array([1, 2, 0])
Comment

python argsort

def g(seq):
    # http://stackoverflow.com/questions/3382352/equivalent-of-numpy-argsort-in-basic-python/3383106#3383106
    #lambda version by Tony Veijalainen
    return [x for x,y in sorted(enumerate(seq), key = lambda x: x[1])]
Comment

PREVIOUS NEXT
Code Example
Python :: How to make a function repeat itself a specifc amount of times python 
Python :: python ide 
Python :: how to put space in between list item in python 
Python :: python with example 
Python :: how to check python to see if list length is even 
Python :: dataclass in python 
Python :: python concatenate dictionaries 
Python :: sqlite python select with parameters 
Python :: python conditionals 
Python :: count items in list python by loop 
Python :: how to make a 2d array in python 
Python :: repl.it install packages python 
Python :: find type of an element in list python 
Python :: mongodb and python 
Python :: append to an array in 1st place python 
Python :: how to use for in python 
Python :: get value of 1 field in model django 
Python :: update python 2 to 3 
Python :: python comments 
Python :: return function in python 
Python :: free wifi connection disconnects frequently windows 10 
Python :: correlation with target variable python 
Python :: Iterating With for Loops in Python 
Python :: python loop 
Python :: check if variable is none 
Python :: convert 2 lists into dictionary 
Python :: get full path of document 
Python :: python all but the last element 
Python :: search and replace in python 
Python :: make button in tk 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =