【发布时间】:2016-12-10 04:42:34
【问题描述】:
在下面的示例中,我正在尝试将多索引 pandas.DataFrame 存储在 h5 文件格式中
import pandas as pd
import numpy as np
store = pd.HDFStore('c:/temp/example.h5')
idx = pd.MultiIndex.from_arrays([['first']*3,['one','two','three']], names = ['outer','inner'])
abc = pd.DataFrame(np.random.randint(1,100,9).reshape(-1,3), index = idx, columns = list('abc'))
如果我尝试存储上面的数据帧('abc')来存储,我得到一个错误,如下所示
store.put('abc',abc,format='t',append=True)
TypeError: shape must be an integer or sequence: 3L
我之前没有收到此错误,可能与 pytable 的版本更新有关。我目前使用的是 3.2.2 版。关于以 h5 格式存储数据帧的替代解决方案的任何指针?
【问题讨论】:
标签: python pandas hdf5 pytables