python_numpy入门_ndarry对象(by official documents)

网友投稿 325 2022-08-30


python_numpy入门_ndarry对象(by official documents)

文章目录

​​official link​​​​基本概念​​​​用于描述ndarray对象的一些属性​​

​​ndarray.ndim​​​​ndarray.shape​​​​ndarray.size​​

​​描述构成ndarray对象中的最基本元素的属性​​

​​ndarray.dtype​​​​ndarray.itemsize​​

​​几乎不用的属性​​

official link

​​user guide​​​​numpy quickStart​​

基本概念

用于描述ndarray对象的一些属性

ndarray.ndim

the number of axes (dimensions) of the array. 该属性描述了ndarry对象的阶数(维数的多少)

ndarray.shape

the dimensions of the array. 该属性描述矩阵各个维度(轴)的长度(size),能够较好体现ndarray的规格 This is a tuple of integers indicating the size of the array in each dimension. For a matrix with n rows and m columns, shape will be (n,m). The length of the shape tuple is therefore the number of axes, ndim. shape属性和ndim属性的关系是,len(shape)==ndim 特殊的,当某个矩阵对象只有一维,那么​​​ndim==1​​​ shape的取值由于是一个元组,单元素元组在括号内以一个​​,​​结尾

ndarray.size

the total number of elements of the array. This is equal to the product of the elements of shape. 该属性描述了这个数组对象的大小(即有多少个最小基本元素),它的大小等于shape元组中各个值的乘积(可以用来粗略衡量一个矩阵的体量)

描述构成ndarray对象中的最基本元素的属性

ndarray.dtype

an object describing the type of the elements in the array. One can create or specify dtype’s using standard Python types. Additionally NumPy provides types of its own. numpy.int32, numpy.int16, and numpy.float64 are some examples. 描述元素的类型

ndarray.itemsize

the size in bytes of each element of the array. For example, an array of elements of type float64 has itemsize 8 (=64/8), while one of type complex32 has itemsize 4 (=32/8). It is equivalent to ndarray.dtype.itemsize. 描述元素的大小

几乎不用的属性

ndarray.data

the buffer containing the actual elements of the array. Normally, we won’t need to use this attribute because we will access the elements in an array using indexing facilities.


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:python_tensorflow安装失败:ERROR: Could not find a version that satisfies the requirement tensorflow(python3.7安装tensorflow失败)
下一篇:MyBatis如何进行双重foreach循环
相关文章

 发表评论

暂时没有评论,来抢沙发吧~