相关疑难解决方法(0)

在HDF5(PyTables)中存储numpy稀疏矩阵

我在使用PyTables存储numpy csr_matrix时遇到问题.我收到这个错误:

TypeError: objects of type ``csr_matrix`` are not supported in this context, sorry; supported objects are: NumPy array, record or scalar; homogeneous list or tuple, integer, float, complex or string
Run Code Online (Sandbox Code Playgroud)

我的代码:

f = tables.openFile(path,'w')

atom = tables.Atom.from_dtype(self.count_vector.dtype)
ds = f.createCArray(f.root, 'count', atom, self.count_vector.shape)
ds[:] = self.count_vector
f.close()
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

谢谢

python numpy hdf5 scipy pytables

21
推荐指数
3
解决办法
6039
查看次数

标签 统计

hdf5 ×1

numpy ×1

pytables ×1

python ×1

scipy ×1