Search code examples
pythonscipysparse-matrix

Argmax of each row or column in scipy sparse matrix


scipy.sparse.coo_matrix.max returns the maximum value of each row or column, given an axis. I would like to know not the value, but the index of the maximum value of each row or column. I haven't found a way to make this in an efficient manner yet, so I'll gladly accept any help.


Solution

  • From scipy version 0.19, both csr_matrix and csc_matrix support argmax() and argmin() methods.