2

I have .mat files with HDF5 data and I want to load it into Python (Pandas DataFrame). I can load the file:

f2 = h5py.File("file.mat")
f2['data']

which is an HDF5 dataset:

<HDF5 dataset "data": shape (9999999, 32), type "<f8">

If I read it with Pandas:

g = pd.read_hdf("file.mat",'data')

I get the following error:

cannot create a storer if the object is not existing nor a value are passed

How do I convert this to a Pandas DataFrame?

1 Answer 1

1

AFAIK you can't read HDF5 files using Pandas methods, that have NOT been written using Pandas.

You can read them using one of the following approaches:

read matlab v7.3 file into python list of numpy arrays via h5py

Reading ALL variables in a .mat file with python h5py

http://poquitopicante.blogspot.de/2014/05/loading-matlab-mat-file-into-pandas.html

Read .mat files in Python

Sign up to request clarification or add additional context in comments.

1 Comment

I suppose knowing it can't be done is the answer I'll have to settle for. I'll probably go the numpy array route. Thanks for the info.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.