python与数据处理:Numpy中的数组(一、简介)

python与数据处理:Numpy中的数组(一、简介)

文本译自Numpy官方API文档,原文附在文末。

Numpy中的数组由ndarray类实现。ndarray是一个能够储存同一类型和位数(译者注:一般是32位或64位)数据的多维数据容器。数组的容量和维数由其本身的形状决定;而对于一个n维数组,其形状又可以由一个元组表示,这个元组拥有n个非负整数,从而能够定义每个维度上的大小。数组内元素的类型由另外一个专门用来定义数据类型的类(dtype)确定。对于每一个数组,dtype是唯一确定的。
如同python中其他的数据容器,我们可以通过索引或切割来获取或修改原数组储存的数据;也可以调用adarray自带的方法和属性(译者注:这里的“属性”指“成员变量”或“域”)对其进行操作。
不同的ndarray可能共享相同的数据,所以对其中一个ndarray的操作可能会对另一个产生影响。在这种情况下,我们称其中一个是另一个的“视图”;相应地,另一个就是这一个的“基”。如果python中的类(如字符串)实现了buffer或array接口,那么这些类也能成为ndarray的“视图”

An ndarray is a (usually fixed-size) multidimensional container of items of the same type and size. The number of dimensions and items in an array is defined by its shape, which is a tuple of N non-negative integers that specify the sizes of each dimension. The type of items in the array is specified by a separate data-type object (dtype), one of which is associated with each ndarray.
As with other container objects in Python, the contents of an ndarray can be accessed and modified by indexing or slicing the array (using, for example, N integers), and via the methods and attributes of the ndarray.
Different ndarrays can share the same data, so that changes made in one ndarray may be visible in another. That is, an ndarray can be a “view” to another ndarray, and the data it is referring to is taken care of by the “base” ndarray. ndarrays can also be views to memory owned by Python strings or objects implementing the buffer or array interfaces.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值