Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/307.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 获取非空scipy稀疏csr矩阵行的索引_Python_Scipy_Sparse Matrix - Fatal编程技术网

Python 获取非空scipy稀疏csr矩阵行的索引

Python 获取非空scipy稀疏csr矩阵行的索引,python,scipy,sparse-matrix,Python,Scipy,Sparse Matrix,我想得到ascipy.sparse.csr\u矩阵中不为空的行的索引。例如: A = [ 0 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 0 ] 期望输出: indices = [0, 2] 代码: 输出: [[0 0 0 0 0 1] [0 0 0 0 0 0] [1 1 0 0 0 0]] [0 2] 零是零???“不零”是指“全零”? [[0 0 0 0 0 1] [0 0 0 0 0 0] [1 1 0 0 0 0]] [0 2

我想得到a
scipy.sparse.csr\u矩阵
中不为空的行的索引。例如:

A = [ 0 0 0 0 0 1
      0 0 0 0 0 0 
      1 1 0 0 0 0 ]
期望输出:

indices = [0, 2]
代码:

输出:

[[0 0 0 0 0 1]
 [0 0 0 0 0 0]
 [1 1 0 0 0 0]]
[0 2]

零是零???“不零”是指“全零”?
[[0 0 0 0 0 1]
 [0 0 0 0 0 0]
 [1 1 0 0 0 0]]
[0 2]