[SciPy-User] how to get indices

Marcel Blattner blattnem@gmail....
Mon Sep 13 03:52:21 CDT 2010


...this rocks...

On Mon, Sep 13, 2010 at 10:28 AM, Gael Varoquaux <
gael.varoquaux@normalesup.org> wrote:

> On Mon, Sep 13, 2010 at 10:16:33AM +0200, Marcel Blattner wrote:
> >    I have a small problem. I have for example a csc_matrix A. I want to
> find
> >    indices of values bigger then a treshold.
> >    In numpy I simply can do: a,b = A > threshold...is there something
> similar
> >    in Scipy?
>
> The difficulty here is that you are dealing with sparse matrices, for
> which access to data is not as simple. I believe the easiest option is to
> convert your matrix to coo, and operate directly on the row/col/data
> arrays:
>
> a = a.tocoo()
> mask = a.data > threshold
> col = a.col[mask]
> row = a.row[mask]
>
> HTH,
>
> Gaël
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20100913/ec846489/attachment.html 


More information about the SciPy-User mailing list