python topN method to get the largest N number or the smallest N number

不言
Release: 2018-06-04 16:01:55
Original
3613 people have browsed it

This article mainly introduces the method of python topN to get the largest N number or the smallest N number. It has a certain reference value. Now I share it with you. Friends in need can refer to it

is as follows:

##

import numpy as np
a = np.array([1,4,3,5,2])
b = np.argsort(a)
print(b)
Copy after login

##print result[0 4 2 1 3]

Explain that a[0] is the smallest and a[3] is the largest

a[0]<a[4]<a[2]<a[1]<a[3]
Copy after login

The above is the detailed content of python topN method to get the largest N number or the smallest N number. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!