博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
The N-dimensional array (ndarray)¶
阅读量:5944 次
发布时间:2019-06-19

本文共 1445 字,大约阅读时间需要 4 分钟。

The N-dimensional array (ndarray)

An 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 , which is a tuple of N positive integers that specify the sizes of each dimension. The type of items in the array is specified by a separate , one of which is associated with each ndarray.

As with other container objects in Python, the contents of an can be accessed and modified by the array (using, for example, N integers), and via the methods and attributes of the .

Different can share the same data, so that changes made in one 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 interfaces.

Example

A 2-dimensional array of size 2 x 3, composed of 4-byte integer elements:

>>> x = np.array([[1, 2, 3], [4, 5, 6]], np.int32)>>> type(x)
>>> x.shape(2, 3)>>> x.dtypedtype('int32')

The array can be indexed using Python container-like syntax:

>>> x[1,2] # i.e., the element of x in the *second* row, *third*column, namely, 6.

For example can produce views of the array:

>>> y = x[:,1]>>> yarray([2, 5])>>> y[0] = 9 # this also changes the corresponding element in x>>> yarray([9, 5])>>> xarray([[1, 9, 3],       [4, 5, 6]])

转载地址:http://frwxx.baihongyu.com/

你可能感兴趣的文章
oracle 分区表
查看>>
字典树--Xor问题
查看>>
Windows 根据进程名杀死进程 kill
查看>>
Eclipse项目启动不了
查看>>
Javascript中的Callback方法浅析
查看>>
HDU1671-Phone List (trie树)
查看>>
Error:java: Compilation failed: internal java compiler
查看>>
笔记。------数组
查看>>
不同数据库中查询前几条记录的用法(SQL Server/Oracle/Postgresql)
查看>>
lab2_selenium测试
查看>>
C# 移位运算符
查看>>
git学习(持续踩坑中
查看>>
无线通信
查看>>
JSONPlaceholder使用
查看>>
java连接redis无法连接,报异常RedisConnectionException
查看>>
【luogu 3375】【模板】KMP字符串匹配
查看>>
MRI原理谁都看得懂版
查看>>
微软面试题 博弈论 经典案例 (参考答案)
查看>>
机器智能公司一览图 | 36氪
查看>>
ByteArrayOutputStream用法
查看>>