0

I have a pandas dataframe that has 3 rows by 3 columns. The dataframe has the following form:

Input Dataframe:

A B C
A1 B1 C1
A2 B2 C2
A3 B3 C3

I want to generate a .mat file from that dataframe and that when I open it in matlab it will be of the 3x3 table type, the same as the dataframe. I have tried the following code:

savemat('matlab.txt', {'df_name': df.to_records(index=False)})

When I do this, it generates the .mat file for me but it does not create a table in matlab, instead it creates a 1x3 structure and then takes the information.

How can I create a matlab file that when opened in matlab is a 3x3 table type?

JDK
  • 217
  • 1
  • 10
  • Does this answer your question? [How to convert a pandas dataframe to a table from within MATLAB?](https://stackoverflow.com/questions/57081181/how-to-convert-a-pandas-dataframe-to-a-table-from-within-matlab) – Ferro Luca Apr 25 '23 at 11:54
  • No, because this answer is with matlab code. I need to make from pandas to matlab file with python. I'm using PyCharm not Matlab. – JDK Apr 25 '23 at 15:08
  • oh i'm sorry, it wasnt quite clear from the question. I think then that it is a duplicate of https://stackoverflow.com/questions/48931576/converting-python-dataframe-to-matlab-file – Ferro Luca Apr 27 '23 at 14:35

0 Answers0