python coo_matrix取某一行或者某一列
最近用到了sparse里面的coo_matrix结构,结果它并不能像以前的list或者numpy根据索引来取某一行或者某一列,那怎么办呢?from scipy import sparseimport numpy as npmatrix = np.array([[9, 8, 7], [6, 5, 4], [3, 2, 1]])mat= sparse.coo_matrix(matrix)print(mat.getcol(1))print(mat.getrow(1))用getrow和getcol就
原创
2020-10-22 09:48:02 ·
2296 阅读 ·
0 评论