January 2019
Intermediate to advanced
390 pages
9h 16m
English
We can also read and write HDF5 files with pandas. To read HDF5 files with pandas, they must first be created with it. For example, let's use pandas to create a HDF5 file containing global power values:
import pandas as pdimport numpy as nparr = np.loadtxt('temp.csv', skiprows=1, usecols=(2,3), delimiter=',')import pandas as pdstore=pd.HDFStore('hdfstore_demo.hdf5')print(store)store['global_power']=pd.DataFrame(arr)store.close()
Now let's read the HDF5 file that we created and print the array back:
import pandas as pdstore=pd.HDFStore('hdfstore_demo.hdf5')print(store)print(store['global_power'])store.close()
The values of the DataFrame can be read in three different ways:
Read now
Unlock full access