【发布时间】:2019-02-02 21:06:48
【问题描述】:
我的 pandas 表的列包含数千行的可变长度列表,例如,
import pandas as pd
df = pd.DataFrame({0: [[1, 2], [3, 4, 5], [7], [8, 9, 10, 11]]}, )
###Output:
df
0
0 [1, 2]
1 [3, 4, 5]
2 [7]
3 [8, 9, 10, 11]
我可以使用
将文件存储在驱动器中with pd.HDFStore('out_file', mode='w') as store:
df.to_hdf(store, key='data1')
但不使用以下,因为列的类型是object。
with pd.HDFStore('out_file', mode='w') as store:
df.to_hdf(store, key='data1', format='table', data_columns=True)
如何从文件中读取少量索引,而不是读取完整的文件然后删除不需要的行?如果 hdf5 不能处理这种类型的数据帧的查询,那么有哪些替代数据格式。谢谢。
【问题讨论】:
标签: python python-2.7 pandas hdf5 hdf