[SciPy-User] How to read row_name, col_name, value format TSV into a sparse matrix?

Peng Yu pengyu.ut at gmail.com
Wed Jan 29 04:33:45 EST 2020


> Reading the csv/tsv (either with pandas or numpy) doesn't create a matrix
> at all. It just gives you the data as it is in the file: values with
> associated coordinates. Then you would use something like
> scipy.sparse.coo_matrix() to convert that to a sparse matrix.

Where it documented that pandas.read_csv don't generate the whole
matrix? The return value is either of the two?

"""
DataFrame or TextParser

    A comma-separated values (csv) file is returned as two-dimensional
data structure with labeled axes.
"""

Are you referring "TextParser"? How to control which one to return? I
don't see an option for it.

Which function of numpy do refer to specifically? numpy.loadtxt? It
returns ndarray, which should read a dense matrix into the memory.

-- 
Regards,
Peng


More information about the SciPy-User mailing list