Can numpy evaluate N largest elements in a multidimensional array?
Say:
import numpy as np
a=[1,2,3]
b=a.max(num_of_max_elements=2) #I know it won't work, and I want it to be 2 and 3
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The easiest way to do this is to sort and then use the last
nnumbers. This can also be done without changing the original array. Here’s an example how to find the largest 10 numbers in a 10×10 array:This code prints something like