Convert mat file to pandas dataframe
问题 I want to convert this file to pandas dataframe. import pandas as pd import scipy.io mat = scipy.io.loadmat('cardio.mat') cardio_df = pd.DataFrame(mat) I get this error : Exception: Data must be 1-dimensional 回答1: It seems mat is a dict containing X of shape (1831, 21) , y with shape (1831, 1) , and some metadata. Assuming X is the data and y are the labels for the same, you can stack them horizontally with np.hstack and load them into pandas: In [1755]: mat = scipy.io.loadmat('cardio.mat')