7

万圣节的熊猫和 HDF 有一些令人毛骨悚然的东西:

df = pandas.DataFrame([['a','b'] for i in range(1,1000)])
store = pandas.HDFStore('test.h5')
store['x'] = df
store.close()

然后

ls -l test.h5
-rw-r--r-- 1 arthur arthur 1072080 Oct 26 10:50 test.h5

1.1M?有点陡峭,但为什么不呢。这就是事情变得非常诡异的地方

store = pandas.HDFStore('test.h5') #open it again
store['x'] = df #do the same thing as before!
store.close()

然后

ls -l test.h5
-rw-r--r-- 1 arthur arthur 2122768 Oct 26 10:52 test.h5

你现在已经进入了暮光区。不用说,运行后store是没有区别的,但是每次迭代都让文件变胖了一点。

似乎只有在涉及字符串时才会发生。在我提交错误报告之前,我想知道我是否在这里遗漏了什么......

4

2 回答 2

4

似乎这可能是原因:http ://www.hdfgroup.org/hdf5-quest.html#del

这是一个大问题 HDF5,wtf。

于 2012-10-26T19:08:56.983 回答
4

是的:“HDF5 不是数据库”。人们经常使用 ptrepack(PyTables 的一部分)来“重新打包”HDF5 文件而没有任何死字节。

于 2012-10-27T13:37:15.390 回答