在python中加载matlab文件时删除keys()



我正在尝试用python加载一个matlab文件,我已经写了以下几行:

import numpy as np
import scipy.io as spio
f = np.load('adj_data.npy',allow_pickle = True)
array1 = np.array(f)
print(array1)
print(type(array1))

运行此代码后,我得到以下结果:

{'__header__': b'MATLAB 5.0 MAT-file, Platform: PCWIN64, Created on: Wed Feb 07 15:26:44 2018', '__version__': '1.0', '__globals__': [], 'A': array([[[0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00],
[1.76007e-02, 2.65923e+00, 3.36400e-01, 3.66851e-02],
[1.47450e-01, 1.98776e+00, 9.35137e-02, 1.11462e-02],
...,
[0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00],
[2.56731e-01, 2.77940e+00, 3.76996e-01, 1.92662e-02],
[1.54293e-02, 2.99425e+00, 6.52976e-01, 3.54300e-02]],
[[1.76007e-02, 2.65923e+00, 3.36400e-01, 3.66851e-02],
[0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00],
[1.65050e-01, 6.71471e-01, 2.42886e-01, 2.55389e-02],
...,
[1.76007e-02, 2.65923e+00, 3.36400e-01, 3.66851e-02],
[2.74331e-01, 1.20168e-01, 4.05960e-02, 5.59513e-02],
[2.17143e-03, 3.35016e-01, 3.16577e-01, 1.25509e-03]],
[[1.47450e-01, 1.98776e+00, 9.35137e-02, 1.11462e-02],
[1.65050e-01, 6.71471e-01, 2.42886e-01, 2.55389e-02],
[0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00],
...,
[1.47450e-01, 1.98776e+00, 9.35137e-02, 1.11462e-02],
[1.09281e-01, 7.91639e-01, 2.83482e-01, 3.04123e-02],
[1.62879e-01, 1.00649e+00, 5.59462e-01, 2.42838e-02]]])}

<class 'numpy.ndarray'>

如何删除数组的第一部分或matlab数组的键((部分:

{'__header__': b'MATLAB 5.0 MAT-file, Platform: PCWIN64, Created on: Wed Feb 07 15:26:44 2018', '__version__': '1.0', '__globals__': [], 'A':

如果是matlab.mat文件(似乎是(,请使用:

import scipy.io as sio
array1 = sio.loadmat('adj_data.npy', mat_dtype = True)['A']

相关内容

  • 没有找到相关文章

最新更新