Eugene Redekop
Eugene Redekop

Reputation: 81

how do I add a pandas object (e.g. DataFrame) to a group within an HDF file?

Suppose I have an HDF5 file (myHDF.h5) with a hierarchy of groups, something like:

/root/groupA
     /groupB

Now I want to add a DataFrame (myFrame) to the groupA (along with some other objects such as dictionaries). How do I do that? If I open my HDF.h5 with pandas.io.HDFStore:

store = pandas.io.HDFStore('myHDF.h5')

and then try:

store['groupA']['myFrame'] = myFrame

I get:

AttributeError: Attribute 'pandas_type' does not exist in node: '/groupA'

What is the proper way to do this?

Upvotes: 2

Views: 2455

Answers (2)

Jeff
Jeff

Reputation: 128918

this is enabled as of version 0.10.0

http://pandas.pydata.org/pandas-docs/stable/io.html#hierarchical-keys

Upvotes: 1

Chang She
Chang She

Reputation: 16970

Currently pandas does not support hierarchical paths as you specified.

There is an open github issue about this: https://github.com/pydata/pandas/issues/13

I'm not sure when we will get around to adding this feature, would more than welcome a pull request if you're interested in completing the skeleton code that's in the issue discussion.

Upvotes: 0

Related Questions