码迷,mamicode.com
首页 > 编程语言 > 详细

「Python」Numpy equivalent of MATLAB's cell array

时间:2018-09-16 12:28:05      阅读:298      评论:0      收藏:0      [点我收藏+]

标签:list   mount   hold   numpy   this   sequence   type   python   cts   

转自Stackoverflow。备忘用。

Question

I want to create a MATLAB-like cell array in Numpy. How can I accomplish this?

Answer

Matlab cell arrays are most similar to Python lists, since they can hold any object - but scipy.io.loadmat imports them as numpy object arrays - which is an array with dtype=object.

To be honest though you are just as well off using Python lists - if you are holding general objects you will loose almost all of the advantages of numpy arrays (which are designed to hold a sequence of values which each take the same amount of memory).

「Python」Numpy equivalent of MATLAB's cell array

标签:list   mount   hold   numpy   this   sequence   type   python   cts   

原文地址:https://www.cnblogs.com/samhx/p/9654817.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!