文章詳情頁
python - numpy 數(shù)據(jù)排序問題
瀏覽:215日期:2022-07-24 11:18:00
問題描述
import numpy as np x = np.array([3, 1, 2])np.argsort(x)Out[4]: array([1, 2, 0]) # 疑問點In [13]: x = np.array([6,5,4,3,2,1])In [14]:In [14]: np.argsort(x)Out[14]: array([5, 4, 3, 2, 1, 0])
為什么不是[2,0,1]
問題解答
回答1:argsort返回的是索引值的排序以np.argsort([3,1,2])來講,對應的索引值是[0, 1, 2], 所以按索引值排序返回的就是[1, 2, 0]
相關文章:
1. boot2docker無法啟動2. docker-compose中volumes的問題3. 關docker hub上有些鏡像的tag被標記““This image has vulnerabilities””4. nignx - docker內(nèi)nginx 80端口被占用5. docker容器呢SSH為什么連不通呢?6. 關于docker下的nginx壓力測試7. docker安裝后出現(xiàn)Cannot connect to the Docker daemon.8. node.js - antdesign怎么集合react-redux對input控件進行初始化賦值9. java - SSH框架中寫分頁時service層中不能注入分頁類10. dockerfile - 為什么docker容器啟動不了?
排行榜

熱門標簽
網(wǎng)公網(wǎng)安備