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

  • Home
  • SEARCH
  • 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 9190783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:32:25+00:00 2026-06-17T20:32:25+00:00

No problem: >>> t = np.array([[1,1,1,1,1],[2,2,2,2,2],[3,3,3,3,3],[4,4,4,4,4],[5,5,5,5,5]]) >>> x = np.arange(5).reshape((-1,1)); y = np.arange(5) >>>

  • 0

No problem:

>>> t = np.array([[1,1,1,1,1],[2,2,2,2,2],[3,3,3,3,3],[4,4,4,4,4],[5,5,5,5,5]])
>>> x = np.arange(5).reshape((-1,1)); y = np.arange(5)
>>> print (t[[x]],t[[y]])

Big problem:

>>> s = scipy.sparse.csr_matrix(t)
>>> print (s[[x]].toarray(),s[[y]].toarray())
Traceback (most recent call last):
  File "<pyshell#22>", line 1, in <module>
:               :
:               :
ValueError: data, indices, and indptr should be rank 1

s.toarray()[[x]] works great, but defeats the whole purpose of me using sparse matrices as my arrays are too big. I’ve checked the Attributes and Methods associated with some of the sparse matrices for anything referencing Advanced Indexing, but no dice. Any ideas?

  • 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-17T20:32:26+00:00Added an answer on June 17, 2026 at 8:32 pm

    sparse matrices have a very limited indexing support, and what is available depends on the format of the matrix.

    For example:

    >>> a = scipy.sparse.rand(100,100,format='coo')
    >>> a[2:5, 6:8]
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: 'coo_matrix' object has no attribute '__getitem__'
    

    but

    >>> a = scipy.sparse.rand(100,100,format='csc')
    >>> a[2:5, 6:8]
    <3x2 sparse matrix of type '<type 'numpy.float64'>'
        with 0 stored elements in Compressed Sparse Column format>
    

    although

    >>> a[2:5:2, 6:8:3]
    Traceback (most recent call last):
    ...
    ValueError: slicing with step != 1 not supported
    

    There is also

    >>> a = scipy.sparse.rand(100,100,format='dok')
    >>> a[2:5:2, 6:8:3]
    Traceback (most recent call last):
    ...
    NotImplementedError: fancy indexing supported over one axis only
    >>> a[2:5:2,1]
    <3x1 sparse matrix of type '<type 'numpy.float64'>'
        with 0 stored elements in Dictionary Of Keys format>
    

    And even

    >>> a = scipy.sparse.rand(100,100,format='lil')
    >>> a[2:5:2,1]
    <2x1 sparse matrix of type '<type 'numpy.int32'>'
        with 0 stored elements in LInked List format>
    C:\Python27\lib\site-packages\scipy\sparse\lil.py:230: SparseEfficiencyWarning: Indexing into a lil_matrix with multiple indices is slow. Pre-converting to CSC or CSR beforehand is more efficient.
      SparseEfficiencyWarning)
    >>> a[2:5:2, 6:8:3]
    <2x1 sparse matrix of type '<type 'numpy.int32'>'
        with 0 stored elements in LInked List format>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Problem: To get the index values of an array to print accordingly in value
Problem Statement is : Given 2 Dimensional array, print output for example If 4
I have a problem like,array with 0 10 indexes and i removed 0th index
iam facing problem in passing array to view. this is my controller code.. function
I have a problem initializing an array whose size is defined as extern const.
I am having a problem understanding how array.sort{ |x,y| block } works exactly, hence
Beginner iOS dev here. I have a problem in my array. Im making an
I'm looking to json_decode a string, but running into a problem with the array
Problem: I have two array where one produce a category and the second produce
I am trying to fix a array problem where it stores images into arrays

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.