Note
Numpy (54) 본문
728x90
How to rank items in an array using numpy?
np.random.seed(10)
a = np.random.randint(20, size=10)
print('Array: ', a)
# Solution
print(a.argsort().argsort())
print('Array: ', a)
#> Array: [ 9 4 15 0 17 16 17 8 9 0]
#> [4 2 6 0 8 7 9 3 5 1]
#> Array: [ 9 4 15 0 17 16 17 8 9 0]
'Numpy' 카테고리의 다른 글
Numpy (56) (0) | 2022.10.18 |
---|---|
Numpy (55) (0) | 2022.10.14 |
Numpy (53) (0) | 2022.09.21 |
Numpy (52) (0) | 2022.09.20 |
Numpy (51) (0) | 2022.09.17 |
Comments