Error converting python DataFrame to Table

I have used the following commands to load in a python .pkl file.
fid = py.open("data.pkl");
data = py.pickle.load(fid);
T = table(data);
This loads a python DataFrame object. Newer versions of MATLAB have the ability to convert this object to a table using the table command, which I tried but encountered the below error:
Error using py.pandas.DataFrame/table
Dimensions of the key and value must be the same, or the value must be scalar.
What does this error mean? I'm guessing it's because the DataFrame object in the .pkl contains a couple nested fields. Most of the fields are simply 1xN numeric vectors, but a couple are 1xN objects which then have their own fields.
How can I convert this DataFrame object to something usable in MATLAB? I was given this datafile and did not generate it, and I am much more proficient in MATLAB than python, so I would rather solve this within MATLAB rather than having to create a python script or change how the file is created.

Respuestas (0)

Productos

Versión

R2025b

Preguntada:

hace alrededor de 6 horas

Editada:

hace alrededor de 6 horas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by