numpy学习

numpy学习2

2.2 The Basics

NumPy’s main object is the homogeneous multidimensional array. It is a table of elements (usually numbers), all of the same type, indexed by a tuple of non-negative integers. In NumPy dimensions are called axes
NumPy的主要对象是同类型的多维数组。它是所有相同类型的元素(通常为数字)表,由非负整数元组索引。在NumPy中,维度称为轴

For example, the coordinates of a point in 3D space [1, 2, 1] has one axis. That axis has 3 elements in it, so we say it has a length of 3. In the example pictured below,the array has 2 axes. The first axis has a length of 2,the second axis has a length of 3.
例如,三维空间[1,2,1]中的点的坐标有一个轴。这个轴有3个元素,所以我们说这个轴的长度为3。在下面的例子中,数组有两个轴。第一个轴的长度是2,第二个轴的长度是3。

[[ 1., 0., 0.], [ 0., 1., 2.]]

NumPy’s array class is called ndarray. It is also known by the alias array. Note that numpy.array is not the same as the Standard Python Library class array.array, which only handles one-dimensional arrays and offers less functionality. The more important attributes of an ndarray object are:
Numpy的数组类被称为ndarray. ndarray也叫别名数组。注意numpy.array与标准库中array.array不一样,array.array仅仅是一维数组,并且提供更少的功能。ndarray提供了更多更加重要的功能。

ndarray.ndim : the number of axes (dimensions) of the array

ndarray.shape: the dimensions of the array. 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
数组的维数。这是一个整数元组,表示每个维度中数组的大小。对于一个有n行和m列的矩阵,形状将是(n,m)。形状元组的长度因此是轴数ndim,这里ndim为2。

ndarray.size: the total number of elements of the array. This is equal to the product of the elements of shape
数组元素的总数。它等于形状元素的乘积

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值