整理python numpy库学习笔记
参考自 https://docs.scipy.org/doc/numpy/user/quickstart.html
和 http://python.jobbole.com/87471/
The Basics
ndarray.ndim:数组的维数(即数组轴的个数),等于秩。最常见的为二维数组(矩阵)。
ndarray.shape:数组的维度。为一个表示数组在每个维度上大小的整数元组。例如二维数组中,表示数组的“行数”和“列数”。ndarray.shape返回一个元组,这个元组的长度就是维度的数目,即ndim属性。
ndarray.size:数组元素的总个数,等于shape属性中元组元素的乘积。
ndarray.dtype:表示数组中元素类型的对象,可使用标准的Python类型创建或指定dtype。另外也可使用前一篇文章中介绍的NumPy提供的数据类型。
ndarray.itemsize:数组中每个元素的字节大小。例如,一个元素类型为float64的数组itemsiz属性值为8(float64占用64个bits,每个字节长度为8,所以64/8,占用8个字节),又如,一个元素类型为complex32的数组item属性为4(32/8)。
ndarray.data:包含实际数组元素的缓冲区,由于一般通过数组的索引获取元素,所以通常不需要使用这个属性。
example
|
|
Array Creation
|
|
Printing Arrays
|
|
Basic Operations
Arithmetic operators
The matrix product
+= and *=
When operating with arrays of different types, the type of the resulting array corresponds to the more general or precise one (a behavior known as upcasting).
|
|
Universal Functions
|
|
Indexing, Slicing and Iterating
One-dimensional arrays
Multidimensional
|
|
Shape Manipulation
|
|
Stacking together different arrays
Splitting one array into several smaller ones
Copies and Views
View or Shallow Copy
deep copy
Fancy indexing and index tricks
Indexing with Arrays of Indices
|
|
|
|
|
|
|
|
Indexing with Boolean Arrays
|
|
|
|
The ix_() function
The ix_ function can be used to combine different vectors so as to obtain the result for each n-uplet.
additional information
|
|
基础运算能力
线性代数模块(linalg)
random 模块