Exemplo pandas.read_hdf5 ()
def test_write_data_frame(hdf_file_path):
key = hdf.EntityKey('cause.test.prevalence')
data = build_table([lambda *args, **kwargs: random.choice([0, 1]), "Kenya", 1],
2005, 2010, columns=('age', 'year', 'sex', 'draw', 'location', 'value'))
non_val_columns = data.columns.difference({'value'})
data = data.set_index(list(non_val_columns))
hdf._write_pandas_data(hdf_file_path, key, data)
written_data = pd.read_hdf(hdf_file_path, key.path)
assert written_data.equals(data)
filter_terms = ['draw == 0']
written_data = pd.read_hdf(hdf_file_path, key.path, where=filter_terms)
assert written_data.equals(data.xs(0, level='draw', drop_level=False))
Shy Skunk