28
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

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
6
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
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?