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 8913955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:35:46+00:00 2026-06-15T04:35:46+00:00

I have a numpy 2d array A , and a list of row numbers

  • 0

I have a numpy 2d array A, and a list of row numbers row_set. How can I get new array B such as if row_set = [0, 2, 5], then B = [A_row[0], A_row[2], A_row[5]]?

I thought of something like this:

def slice_matrix(A, row_set):
    slice = array([row for row in A if row_num in row_set])

but I don’t have any idea, how can I get a row_num.

  • 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-15T04:35:48+00:00Added an answer on June 15, 2026 at 4:35 am

    Use take():

    In [87]: m = np.random.random((6, 2))
    
    In [88]: m
    Out[88]: 
    array([[ 0.6641412 ,  0.31556053],
           [ 0.11480163,  0.00143887],
           [ 0.4677745 ,  0.43055324],
           [ 0.49749099,  0.15678506],
           [ 0.48024596,  0.65701218],
           [ 0.48952677,  0.97089177]])
    
    In [89]: m.take([0, 2, 5], axis=0)
    Out[89]: 
    array([[ 0.6641412 ,  0.31556053],
           [ 0.4677745 ,  0.43055324],
           [ 0.48952677,  0.97089177]])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an numpy array which I save to a image using savefig(). Then
If I have a list of numpy arrays, then using remove method returns a
I have a numpy object array containing several lists of index numbers: >>> idxLsts
I have a 1D numpy array containing complex numbers (eg. numpy.complex64). I need to
I have a 48x365 element numpy array where each element is a list containing
I have a list of 3D points stored in numpy array A with shape
I have two identically-sized numpy.array objects (both one-dimensional), one of which contains a list
I have 1-dimensional numpy array ( array_ ) and a Python list (list_). The
I have a Numpy array and a list of indices whose values I would
I have a numpy array like this: x = np.array([[1,2,3],[4,5,6],[7,8,9]]) I need to create

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.