【发布时间】:2012-06-23 04:08:16
【问题描述】:
我在使用 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
我的代码:
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()
有什么想法吗?
谢谢
【问题讨论】:
-
您是否担心磁盘上的数据大小?我认为 hdf5 文件可以以压缩格式存储,在这种情况下,您可能只需存储密集矩阵即可。
-
见stackoverflow.com/questions/8895120/…,好像没有对稀疏矩阵的pytables支持。
标签: python numpy scipy hdf5 pytables