我正在使用sio.savemat
将字典保存到.mat中。我有以下代码,结果是一个大小为(209374,8)
且类型为string96
的numpy数组:
import scipy.io as sio
column=['some','numbers','12oh','and','some','pure','caracter','strings']
final = { column[0] : result[:,0]}
for i in range(1,np.size(column)):
final[column[i]]= result[:,i]
sio.savemat('/some/directory/name.mat', final)
运行后,我收到以下错误消息,我无法确定如何解决:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 540, in runfile
execfile(filename, namespace)
File "/home/florian/Documents/eval/python/ofr.py", line 88, in <module>
sio.savemat('/home/florian/Documents/eval/tiwa/mat/ofr.mat', final)
File "/usr/lib/python2.7/dist-packages/scipy/io/matlab/mio.py", line 204, in savemat
MW.put_variables(mdict)
File "/usr/lib/python2.7/dist-packages/scipy/io/matlab/mio5.py", line 872, in put_variables
self._matrix_writer.write_top(var, asbytes(name), is_global)
File "/usr/lib/python2.7/dist-packages/scipy/io/matlab/mio5.py", line 622, in write_top
self.write(arr)
File "/usr/lib/python2.7/dist-packages/scipy/io/matlab/mio5.py", line 657, in write
self.write_char(narr, codec)
File "/usr/lib/python2.7/dist-packages/scipy/io/matlab/mio5.py", line 707, in write_char
arr = arr_to_chars(arr)
File "/usr/lib/python2.7/dist-packages/scipy/io/matlab/miobase.py", line 402, in arr_to_chars
buffer=arr)
TypeError: expected a single-segment buffer object
我的系统规格:
因为我不知道在哪里感谢任何帮助或提示。