我一直在处理一些文本数据,有一些稀疏矩阵和密集(numpy数组)。我只是想知道如何正确地将它们组合起来。
这些是数组的类型和形状:
list1
<109248x9 sparse matrix of type '<class 'numpy.int64'>'
with 152643 stored elements in Compressed Sparse Row format>
list2
<109248x3141 sparse matrix of type '<class 'numpy.int64'>'
with 350145 stored elements in Compressed Sparse Row format>
list3.shape , type(list3)
(109248, 300) , numpy.ndarray
list4.shape , type
(109248, 51) , numpy.ndarray
我希望将它们合并成一个密集的矩阵。我尝试了一些vstack和hstack,但没能弄清楚。非常感谢任何帮助。
Output required: (109248, 3501)
list1.A
,然后将所有4个列表进行hstack
。 - hpauljlist2.toarray()
,但出现了错误。内存错误
。是否可以直接合并它们,而无需实际转换为密集数组? - user_6396sparse.hstack
。 - hpaulj