Skip to content

ENH: Iterate over HDF store hierarchically #10143

Closed
@nileracecrew

Description

@nileracecrew

I am relatively new to pandas, but have been using raw HDF5 files for a long itme, so apologies if this feature or something equivalent already exists.

As stated in the documentation, it is possible to create hierarchies of data stores:

store.put('/first_group/df1', df1)
store.put('/first_group/df2', df2)
store.put('/second_group/df3', df3)

However, it seems that store.keys() can only provide a flattened list of all available groups. It would be nice to be able to walk the HDF5 file hierarchically. A couple examples (this is borrowing a bit from the h5py API):

# do stuff on each subgroup/substore in /first_group
for s in store['first_group'].values() :
    # do stuff on df1 and df2

# visit each group at the root level
for s in store.values() :
    if 'df1' in s :
        # do stuff on any store named 'df1'

The main use case I would have for something like this is that I have many dataframes with different schema but would like to group some of them together and then iterate through those groups.

Best way I can think to emulate this is to parse the strings in store.keys(), but that is pretty ugly.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions