小编131*_*13e的帖子

How to use numpy.argsort() as indices in more than 2 dimensions?

I know something similar to this question has been asked many times over already, but all answers given to similar questions only seem to work for arrays with 2 dimensions.

My understanding of np.argsort() is that np.sort(array) == array[np.argsort(array)] should be True. I have found out that this is indeed correct if np.ndim(array) == 2, but it gives different results if np.ndim(array) > 2.

Example:

>>> array = np.array([[[ 0.81774634,  0.62078744],
                       [ 0.43912609,  0.29718462]],
                      [[ 0.1266578 , …
Run Code Online (Sandbox Code Playgroud)

python arrays sorting numpy

8
推荐指数
1
解决办法
1611
查看次数

标签 统计

arrays ×1

numpy ×1

python ×1

sorting ×1