HDF5ファイルから特定の列のみを読み込み、それらの列に条件を渡したい。私の懸念は、私はメモリ内のデータフレームとしてすべてのHDF5ファイルを取得したくないということです。私は自分の必要条件を満たしたカラムだけを手に入れたいです。hdf5ファイルから特定の列を読み込み、条件を渡す
columns=['col1', 'col2']
condition= "col2==1"
groupname='\path\to\group'
Hdf5File=os.path.join('path\to\hdf5.h5')
with pd.HDFStore(Hdf5File, mode='r', format='table') as store:
if groupname in store:
df=pd.read_hdf(store, key=groupname, columns=columns, where=["col2==1"])
私はエラーを取得する:
TypeError: cannot pass a column specification when reading a Fixed format store. this store must be selected in its entirety
は、それから私は、特定の列のみを返す行の下に使用します。
df=store[groupname][columns]
しかし、私は、私はそれに条件を渡すことができる方法を知ってはいけません。
可能な重複read \ _hdfとHDFStore.selectを使用してHDF5ファイルから特定の値を取得する](https://stackoverflow.com/questions/26302480/python-pandas-reading-specific-values-from -hdf5-files-using-read-hdf-and-hdfstor) –