LoginSignup
28
5

More than 5 years have passed since last update.

Numpyのargsortの結果を降順で受け取る

Last updated at Posted at 2018-02-15

numpy.argsortにはデフォルトで昇順でしか結果を受け取れません、
また降順にするオプションもありません。そこで今回は降順に結果を受け取る方法を紹介します。

import numpy as np

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

print(np.argsort(x))

# array([1, 2, 0])

print(np.argsort(-x))

# array([0, 2, 1])

以上です。

参考

28
5
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
28
5