Run ❯
Get your
own Python
server
×
Change Orientation
Change Theme, Dark/Light
Go to Spaces
import numpy as np from scipy.sparse import csr_matrix arr = np.array([[0, 0, 0], [0, 0, 1], [1, 0, 2]]) mat = csr_matrix(arr) mat.sum_duplicates() print(mat)
(1, 2) 1 (2, 0) 1 (2, 2) 2