尝试通过pd.HDFStore('mystore.h5', mode='a').append(my_frame, chunk)
. 这些块在列和类型方面都是相同的(它们来自同一个数据框)但是它适用于很多块然后在中途爆炸。
ValueError: cannot match existing table structure for [Net_Bal_Amt,Loan_Current_Rate] on appending data
我打印出导致此失败的数据帧块,它们的共同点是特定列的所有“无”值(它们最初从源中为空)。不知道如何纠正这一点。只要它们为空,它们就应该保持为 None 或 NaN 或 null。谢谢。
Traceback (most recent call last):
File "[...]\Anaconda3\lib\site-packages\pandas\io\pytables.py", line 3381, in create_axes
b, b_items = by_items.pop(items)
KeyError: ('Net_Bal_Amt', 'Loan_Current_Rate')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "[...]\crd_test.py", line 8, in <module>
credit.CRD.hdf_install(overwrite=True, tablenames=['loans_uscrd', 'loans_uscrd_a'])
File "[...]\credit_base.py", line 62, in hdf_install
cls._hdf_creation(map_)
File "[...]\credit_base.py", line 80, in _hdf_creation
cls._hdf_processing(v, chunk)
File "[...]\credit_base.py", line 88, in _hdf_processing
cls.crd.append(frame, chunk)
File "[...]\Anaconda3\lib\site-packages\pandas\io\pytables.py", line 903, in append
**kwargs)
File "[...]\lib\site-packages\pandas\io\pytables.py", line 1259, in _write_to_group
s.write(obj=value, append=append, complib=complib, **kwargs)
File "[...]\lib\site-packages\pandas\io\pytables.py", line 3751, in write
**kwargs)
File "[...]\Anaconda3\lib\site-packages\pandas\io\pytables.py", line 3388, in create_axes
item in items))
ValueError: cannot match existing table structure for [Net_Bal_Amt,Loan_Current_Rate] on appending data
数据类型:
pd.read_hdf(r'[...]\crd_test.h5','loans').dtypes
Out[4]:
Customer_Id object
As_of_Date datetime64[ns]
Net_Bal_Amt float64
Loan_Current_Rate float64
dtype: object
版本:pytables:3.1.1 熊猫:0.15.2 python:3.4
崩溃时附加的块的 dtypes:
Customer_Id object
As_of_Date datetime64[ns]
Net_Bal_Amt float64
Loan_Current_Rate object
dtype: object