使用pandas将带有字符串值的数据帧块附加到大型HDF5文件时出现异常

使用pandas将带有字符串值的数据帧块附加到大型HDF5文件时出现异常,pandas,hdf5,hdfstore,Pandas,Hdf5,Hdfstore,当filesize大于大约47 GiB后,向HDF5存储追加带有字符串值(数值可以)的pandas.DataFrame()时发生异常。字符串的最小大小、记录数和列数都不重要。文件大小很重要 异常跟踪的底部: File "..\..\hdf5-1.8.14\src\H5FDsec2.c", line 822, in H5FD_sec2_write file write failed: time = Tue Aug 18 18:26:17 2015 , filename = 'large_fil

当filesize大于大约47 GiB后,向HDF5存储追加带有字符串值(数值可以)的
pandas.DataFrame()
时发生异常。字符串的最小大小、记录数和列数都不重要。文件大小很重要

异常跟踪的底部:

  File "..\..\hdf5-1.8.14\src\H5FDsec2.c", line 822, in H5FD_sec2_write
file write failed: time = Tue Aug 18 18:26:17 2015
, filename = 'large_file.h5', file descriptor = 4, errno = 22, error message = 'Invalid argument', buf = 0000000066A40018, total write size = 262095, bytes this sub-write = 262095, bytes actually written = 18446744073709551615, offset = 47615949533
要复制的代码:

import numpy as np
import pandas as pd

for i in range(200):
    df = pd.DataFrame(np.char.mod('random string object (%f)', np.random.rand(5000000,3)), columns=('A','B','C'))
    print('writing chunk №', i, '...', end='', flush=True)
    with pd.HDFStore('large_file.h5') as hdf:
        # Construct unique index
        try:
            nrows = hdf.get_storer('df').nrows
        except:
            nrows = 0
        df.index = pd.Series(df.index) + nrows    

        # Append the dataframe to the storage. Exception hppens here
        hdf.append('df', df, format='table')
    print('done')
环境: Windows7 x64机器、python 3.4.3、pandas 0.16.2、pytables 3.2.0、HDF5 1.8.14


问题是如果问题位于上面的python代码中,如何修复该问题,或者如果与HDF5相关,如何避免该问题。谢谢。

最近试用Pytables 3.2.1版本Pytables 3.2.1并没有解决这个问题,您可以试试hdfgroup。这看起来像是HDF5本身的一个例外。如果我从hdfgroup得到答案,我将在这里提供反馈。假设,问题也可能出现在DataFrame布局中(DataFrame引用它的字符串对象,这些对象实际上存储在不同的位置),并且PyTables在HDF5中序列化它的方式。hdfgroup的支持响应速度非常快。这看起来像是我自己的配置问题。同样的代码在另一台电脑上运行得很好。试用Pytables 3.2.1版本最近Pytables 3.2.1并没有解决这个问题。你可以试试hdfgroup。这看起来像是HDF5本身的一个例外。如果我从hdfgroup得到答案,我将在这里提供反馈。假设,问题也可能出现在DataFrame布局中(DataFrame引用它的字符串对象,这些对象实际上存储在不同的位置),并且PyTables在HDF5中序列化它的方式。hdfgroup的支持响应速度非常快。这看起来像是我自己的配置问题。同样的代码在另一台电脑上运行良好。