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 :: leap year 
Python :: count down for loop python 
Python :: string to binary python 
Python :: convert pdf to csv python 
Python :: pandas look for values in column with condition 
Python :: how to use path to change working directory in python 
Python :: python check tuple length 
Python :: python list 
Python :: count unique elements in list python 
Python :: return max value in groupby pyspark 
Python :: how to make a resizable python tkinter window have a limit 
Python :: python how to get the folder name of a file 
Python :: streamlit button 
Python :: python count array length 
Python :: python open all files of type csv 
Python :: management commands django 
Python :: boto3 client python 
Python :: dictionary indexing python 
Python :: qtablewidget clear python 
Python :: pandas read excel with two headers 
Python :: how to get time in python 
Python :: multiple boxplots python 
Python :: set column datatype pandas 
Python :: python aes encryption 
Python :: how to install python dill 
Python :: python re compile 
Python :: python mettre en minuscule 
Python :: word guessing game python 
Python :: python write text file on the next line 
Python :: python submit work to redis 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =