今天小編就為大家分享一篇python numpy 部分排序 尋找最大的前幾個數,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
如下所示:文章源自四五設計網-http://www.wasochina.com/40178.html
1 2 3 4 | import numpy as np K = 4 a = np.array([ 0 , 8 , 0 , 4 , 5 , 8 , 8 , 0 , 4 , 2 ]) a[np.argpartition(a, - K)[ - K:]] |
以上這篇python numpy 部分排序 尋找最大的前幾個數的方法就是小編分享給大家的全部內容了,希望能給大家一個參考。文章源自四五設計網-http://www.wasochina.com/40178.html 文章源自四五設計網-http://www.wasochina.com/40178.html
我的微信
微信掃一掃

我的微信
惠生活福利社
微信掃一掃

我的公眾號
評論