-
-
Save stevenferrer/f708d2920a5ae7920b6f603a60bfdc76 to your computer and use it in GitHub Desktop.
How to import structured matlab data into python with scipy | prototype | http://bit.ly/1cdqxQc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
from scipy.io import loadmat | |
dot_mat_file = 'numpy-opttheta.mat' | |
data = loadmat(dot_mat_file) | |
print type(data) # ==> Out[9]: dict | |
print '*' * 79 | |
for key in data.keys(): | |
print key,' ', type(data[key]) | |
print '*' * 79 | |
df = pd.DataFrame(data['opttheta'], columns=['opt_theta']) | |
nrow, ncol = df.shape | |
print 'nrow: %d' % nrow | |
print 'ncol: %d\n' % ncol | |
print df.head() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment