我在 R 中有一个非常大且稀疏的矩阵,是使用“Matrix”包创建的,我想在 python + numpy 中处理。R 对象采用 csc 格式,如果我使用 Matrix 包中的 writeMM 函数将其导出,则输出如下所示:
%%MatrixMarket matrix coordinate real general
4589 17366 160441
22 1 5.954510725783322
36 1 29.77255362891661
41 1 23.81804290313329
74 1 5.954510725783322
116 1 59.54510725783322
127 1 11.909021451566645
159 1 17.863532177349967
Run Code Online (Sandbox Code Playgroud)
其中第一列是行,第二列是列,第三列是值。
我想知道如何将其导入到 python 中。我看到 scipy 有一个用于操作列压缩稀疏矩阵的模块,但它没有从文件创建稀疏矩阵的功能。