SciPy

scipy.sparse.spmatrix.sum

spmatrix.sum(axis=None)[source]

Sum the matrix over the given axis. If the axis is None, sum over both rows and columns, returning a scalar.