且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Python pandas 使用read_hdf和HDFStore.select从HDF5文件读取特定值

更新时间:2022-12-08 11:00:55

您需要指定data_columns=(也可以使用True使所有列都可搜索)

You need to specify data_columns= (you can use True as well to make all columns searchable)

(仅供参考,mode='w'将重新开始文件,仅以我为例)

(FYI, the mode='w' will start the file over, and is just for my example)

In [50]: df_tl.to_hdf('STORAGE2.h5','table',append=True,mode='w',data_columns=['A'])

In [51]: pd.read_hdf('STORAGE2.h5','table',where='A>2')
Out[51]: 
   A  B
3  3  3
4  4  4