Set row of csr_matrix

前端 未结 5 2065
旧巷少年郎
旧巷少年郎 2020-12-18 12:04

I have a sparse csr_matrix, and I want to change the values of a single row to different values. I can\'t find an easy and efficient implementation however. This is what it

5条回答
  •  春和景丽
    2020-12-18 12:37

    This is my approach:

    A = A.tolil()
    A[index, :] = new_row
    A = A.tocsr()
    

    Just convert to lil_matrix, change the row and convert back.

提交回复
热议问题