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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:51:24+00:00 2026-06-10T11:51:24+00:00

I have an array y and a matrix X that is CSR sparse. I

  • 0

I have an array y and a matrix X that is CSR sparse.

I need to do a random sort of y and X where each row of y corresponds to a row in X.

Using NumPy, how do I do that?

  • 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-10T11:51:25+00:00Added an answer on June 10, 2026 at 11:51 am

    In order to get a random sort, you could try to use the np.random.shuffle function.

    # Create an array of indices
    indices = np.arange(y.size)
    # Randomize it
    np.random.shuffle(indices)
    

    You can now use indices to randomize y with fancy indexing y_new = y[indices].

    You could use the same indices to reorder your matrix, but be careful, CSR matrices don’t support fancy indexing. You’ll have to transform it to LIL, reorder it, then retransform it to CSR.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using numpy. I have one array Y and one matrix X .
Suppose that I have a 2D array (matrix) in Java like this... int[][] MyMat
I have a matrix in the type of a Numpy array. How would I
I have a sparse matrix that is not symmetric I.E. the sparsity is somewhat
I have an NxM array in numpy that I would like to take the
I need a matrix that holds only 1 or 0 for each element. What
I have a quadratic matrix(two-dimensional dynamic array of pointers) and need to change rows/columns
I'm working on a sparse matrix class that needs to use an array of
I have a 2D numpy array (i.e matrix) A which contains useful data interspread
I have this code: $id = new matrix(array(0=>array(1,0.5,3), 1=>array(2,1,4), 2=>array(1/3,1/4,1))); $soma = $id->times($id)->sumRows(); That

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.