python - SciPy Sparse Array: Get index for a data point -


i creating csr sparse array (because have lot of empty elements/cells) need use forwards , backwards. is, need input 2 indices , element corresponds ( matrix[0][9]=34) need able indices upon knowing value 34. elements in array unique. have looked on answer regarding this, have not found one, or may have not understood looking if did! i'm quite new python, if make sure let me know functions find , steps retrieve indices element, appreciate it!

thanks in advance!

here's way of finding specific value applicable both numpy arrays , sparse matrices

in [119]: a=sparse.csr_matrix(np.arange(12).reshape(3,4))  in [120]: a==10 out[120]:  <3x4 sparse matrix of type '<class 'numpy.bool_'>'     1 stored elements in compressed sparse row format>  in [121]: (a==10).nonzero() out[121]: (array([2], dtype=int32), array([2], dtype=int32))  in [122]: (a.a==10).nonzero() out[122]: (array([2], dtype=int32), array([2], dtype=int32)) 

Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -