“Argsort nu” Réponses codées

Argsort nu

# Python program explaining
# argpartition() function
   
import numpy as geek
  
# input array
in_arr = geek.array([ 2, 0,  1, 5, 4, 1, 9])
print ("Input unsorted array : ", in_arr) 
  
out_arr = geek.argsort(in_arr)
print ("Output sorted array indices : ", out_arr)
print("Output sorted array : ", in_arr[out_arr])
Tame Tarantula

Argsort nu

ind = np.argsort(x, axis=0)  # sorts along first axis (down)
ind
array([[0, 1],
       [1, 0]])
np.take_along_axis(x, ind, axis=0)  # same as np.sort(x, axis=0)
array([[0, 2],
       [2, 3]])
Tame Tarantula

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])]
Erwin Smith

Argsort nu

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

Argsort nu

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

Réponses similaires à “Argsort nu”

Questions similaires à “Argsort nu”

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code