2
我有一个稀疏矩阵可以说A.转换SciPy的稀疏矩阵元组
其中
type(A)
scipy.sparse.csr.csr_matrix
和A
<100x100 sparse matrix of type '<class 'numpy.int64'>'
with 198 stored elements in Compressed Sparse Row format>
低于以下是获得
(0, 1) 1
(0, 0) 1
(0, 2) 1
(0, 3) 1
(0, 4) 1
(0, 5) 1
(0, 6) 1
....
它代表矩阵A的非零元素(下面的代码)
for a in A:
print(a)
如何将它转换为数据结构如下图所示:
[(0,1),
(0,0),
(0,2),
....]