我有一个存储在文件中的面板,我想将更多数据附加到该面板并附加到内存中工作正常,但是当尝试将数据附加到文件时出现此错误:
import pandas as pd
import numpy as np
df = pd.DataFrame(data = np.random.randn(5,6),columns=('a','b','c','d','e','f'))
pw = pd.Panel(major_axis = df.columns,minor_axis=df.index)
pw2 = pd.Panel(major_axis = df.columns,minor_axis=df.index)
pw['A'] = df
pw['B'] = df*2
pw['C'] = df*3
pw2['D'] = df*4
pw.to_hdf('proc.h5','proc' , mode='w',format='table',append=True)
pw2.to_hdf('proc.h5','proc' , mode='a',format='table',append=True)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\pandas\core\generic.py", line 884, in to_hdf
return pytables.to_hdf(path_or_buf, key, self, **kwargs)
File "C:\Python27\lib\site-packages\pandas\io\pytables.py", line 279, in to_hdf
f(store)
File "C:\Python27\lib\site-packages\pandas\io\pytables.py", line 272, in <lambda>
f = lambda store: store.append(key, value, **kwargs)
File "C:\Python27\lib\site-packages\pandas\io\pytables.py", line 914, in append
**kwargs)
File "C:\Python27\lib\site-packages\pandas\io\pytables.py", line 1273, in _write_to_group
s.write(obj=value, append=append, complib=complib, **kwargs)
File "C:\Python27\lib\site-packages\pandas\io\pytables.py", line 3578, in write
**kwargs)
File "C:\Python27\lib\site-packages\pandas\io\pytables.py", line 3229, in create_axes
item in items))
ValueError: cannot match existing table structure for [A,B,C] on appending data