[SciPy-user] Creating a sparse matrix
Robert Cimrman
cimrman3 at ntc.zcu.cz
Thu Dec 13 08:03:14 EST 2007
Nils Wagner wrote:
> Hi all,
>
> How can I build a sparse matrix from the following array ?
>>>> data
> array([['1', '1', '1.7244067583090530E+05'],
> ['1', '2', '4.7526228631699840E+04'],
> ...
> ['18', '24', '-1.0245630931609220E+03'],
> ['24', '24', '4.2234547103090340E+03']],
> dtype='|S23')
>
> data contains information about row, column and the
> corresponding entry.
>
> Any pointer would be appreciated.
You read the data from a file, right? You should convert the row/column
indices to integers and values to floats during the reading. Then you
would have your data ready for the COO matrix constructor.
r.
More information about the SciPy-User
mailing list