转换2D numpy数组列表的列表

我使用外部模块( libsvm ),它不支持numpy数组,只有元组,列表和字典。 但我的数据是在一个2D numpy数组。 我怎样才能转换pythonic的方式,又名无循环。

>>> import numpy >>> array = numpy.ones((2,4)) >>> data_list = list(array) >>> data_list [array([ 1., 1., 1., 1.]), array([ 1., 1., 1., 1.])] >>> type(data_list[0]) <type 'numpy.ndarray'> # <= what I don't want # non pythonic way using for loop >>> newdata=list() >>> for line in data_list: ... line = list(line) ... newdata.append(line) >>> type(newdata[0]) <type 'list'> # <= what I want 
 >>> import numpy >>> a = numpy.ones((2,4)) >>> a array([[ 1., 1., 1., 1.], [ 1., 1., 1., 1.]]) >>> a.tolist() [[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]] >>> type(a.tolist()) <type 'list'> >>> type(a.tolist()[0]) <type 'list'>