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