【发布时间】:2018-04-29 15:21:23
【问题描述】:
如何有效地重塑和 scipy.sparse csr_matrix?
我需要在最后添加零行。 使用:
from scipy.sparse import csr_matrix
data = [1,2,3,4,5,6]
col = [0,0,0,1,1,1]
row = [0,1,2,0,1,2]
a = csr_matrix((data, (row, col)))
a.reshape(3,5)
我收到此错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/scipy/sparse/base.py", line 129, in reshape
self.__class__.__name__)
NotImplementedError: Reshaping not implemented for csr_matrix.
【问题讨论】:
标签: scipy sparse-matrix reshape