Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7819707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:03:22+00:00 2026-06-02T07:03:22+00:00

Can numpy evaluate N largest elements in a multidimensional array? Say: import numpy as

  • 0

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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T07:03:22+00:00Added an answer on June 2, 2026 at 7:03 am

    The easiest way to do this is to sort and then use the last n numbers. 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:

    a = numpy.random.randint(1000, size=100).reshape(10, 10)
    indices = a.ravel().argsort()
    print a.ravel()[indices[-10:]]
    

    This code prints something like

    array([909, 917, 926, 936, 952, 960, 961, 964, 969, 993])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

import numpy a = numpy.array([20090913, 20101020, 20110125]) Can you explain why numpy.datetime64(a.astype(S8).tolist()) converts correctly
How can i store a list within a numpy 2d array? import numpy A
How can I import an array to python (numpy.arry) from a file and that
How can I put a numpy multidimensional array in a HDF5 file using PyTables?
How can I build a numpy array out of a generator object? Let me
I can index a 2d numpy array with a tuple or even a list
How can I know the (row, column) index of the minimum of a numpy
I have a 2d array in numpy where I want to insert a new
I am trying to work with PyTables and NumPy . Can you please tell
NumPy arrays can be indexed with an array of booleans to select the rows

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.