Examples

In [1]:
import numpy as np
import pandas as pd
In [2]:
df = pd.DataFrame({'P': [2, 3, 4], 'Q': [5, 6, 7]},
                  index=['p', 'q', 'r'])
df.to_hdf('data.h5', key='df', mode='w')

We can add another object to the same file:

In [3]:
s = pd.Series([2, 3, 4, 5])
s.to_hdf('data.h5', key='s')

Reading from HDF file:

In [4]:
pd.read_hdf('data.h5', 'df')
Out[4]:
P Q
p 2 5
q 3 6
r 4 7
In [5]:
pd.read_hdf('data.h5', 's')
Out[5]:
0    2
1    3
2    4
3    5
dtype: int64

Deleting file with data:

In [6]:
import os
os.remove('data.h5')