文件名称:
NumPy Reference.pdf
开发工具:
文件大小: 5mb
下载次数: 0
上传时间: 2019-10-08
详细说明:文档详细介绍了Python NumPy 数据处理库的功能、函数、以及相关示例,极具参考、学习价值。CONTENTS
I Array objec
1.1 The N-dimensional array (ndarray)
2 Scala
1.3 Data type objects(dt ype)
1. 4 Indexing
l04
111
1.6 SLandard array subclasses
.122
1.7 Masked arrays
1. 8 The Array Interface
431
1. 9 Datetimes and Timedeltas
...436
2 Universal functions (ufunc)
445
2. Broadcasti
445
2.2 Output type determination
446
2.3 Use of internal buffers
446
2.4 Error handling
446
2.5 Casting rules
449
2.6 Overriding Func behavior
451
2.7 func
451
2.8 Available ufuncs
461
3 Routin
465
3.1 Array creation routines
465
3.2 Array manipulation routines
.502
3.3 Binary operations
..548
3.5
C-Types Foreign Function Interface (numpy. ctypeslib/
3.4 String operations
555
601
3.6 Datetime Support Functions
3.7 Data type routines ...
608
3.8 Optionally Scipy-accelerated routines (numpy dual)
626
3.9 Mathematical functions with automatic domain(numpy emath)
.627
3.10 Floating point error handling
..628
3.11 Discrete Fourier Transform(numpy fft)
.634
3.12 Financial functions
658
3.13 Functional programming
668
3.14 Numpy-specific help functions
..674
3.15 Indexing routines
676
3.16 Input and output
710
3. 17 Lincar algebra(numpy. linalg)
737
3. 18 Logic functions
··
..775
3.19 Masked array operations
793
3.20 Mathematical functions
,,,..915
3.21 Matrix library (numpy. matlib)
985
3.22 Miscellaneous routines
990
3.23 Padding Arrays
994
3.24 Polynomials
997
3.25 Random sampling(numpy random)
..,,,1173
3.26 Set routines
1275
3.27 Sorting, searching, and counting
·
..1280
3.28 Statistics
3.29 Test Support(numpy testing)
1334
3.30 Window functions
1347
4 Packaging(numpy distutils)
1355
4.1 Modules in numpy distutils
1355
4.2 Building Installable C libraries
1366
4.3 Conversion of, src fles
1367
5 Numpy C·API
1369
5.1 Python Types and C-Structures
,,,,,1369
5.2 System configuration
1382
5.3 Data Type API
1383
5.4 Array API
1388
5.5
rray Iterator API
1428
5.6 FUnc API
..14415
5.7 Generalized Universal Function APl
1451
5.8 Numpy core libraries
.,.,.1454
5.9 C API Deprecations
,,..,,,1459
6 Numpy internals
1461
6. 1 Numpy c Code explanations
146I
6.2 Internal organization of numpy arrays
1468
6.3 Multidimensional Array Indexing Order Issues
1468
7 Numpy and SWIG
1471
7.1 Numpy. 1: a SWIG Interface File for NumPy
l471
7.2 Testing the numpy. i Typemaps
1486
8 Acknowledgements
1489
Bibliography
1491
Index
1501
Num Py Reference, Release 1.12.0.devo+e6593fb
Release
1.12.deV0
Date
May29,2016
This reference manual details functions, modules, and objects included in Numpy, describing what they are and what
they do. For learning how to use NumPy, see also user.
CONTENTS
NumPy Reference, Release 1.12.0.dev0+e6593fb
CONTENTS
CHAPTER
ONE
ARRAY OBJECTS
NumPy provides an N-dimensional array type, the ndarray, which describes a collection of"items"of the same type
The items can be indexed using for example n integers
All ndarrays are homogenous: every item takes up the same size block of memory, and all blocks are interpreted in
xactly the same way. How each item in the array is to be interpreted is specified by a separate data-type object, one
of which is associated with every array. In addition to basic types (integers, floats, etc. ) the data type objects can also
represent data structures
An item extracted from an array, e.g. by indexing, is represented by a Python object whose type is one of the array
scalar types built in Numpy. The array scalars allow easy manipulation of also more complicated arrangements of
head
data-type
y
scalar
header
●●
ndarray
Figure 1.1: Figure Conceptual diagram showing the relationship between the three fundamental objects used to de-
scribe the data in an array: 1) the ndarray itself, 2)the data-type object that describes the layout of a single fixed-size
element of the array, 3)the array-scalar Python object that is returned when a single element of the array is accessed
1.1 The N-dimensional 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 positive 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 arrayusing, for example, N integers), and via the methods and attributes of the ndarray
3
NumPy Reference, Release 1.12.0.devo+e6593fb
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
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.-nL32)
>>>
(2,3)
yp
dtype(int32)
The array can be indexed using Python container-like syntax
>>> The element of x in the *second* row, *third* column, namely,6
x[1,2]
For example slicing can produce views of the arra
y([2,5])
>>>y[o]=9 this also changes the corresponding element inx
array([9, 51
array([[1,9,3]
[4,5,6]1)
1.1.1 Constructing arrays
New arrays can be constructed using the routines detailed in Array creation routines, and also by using the low-level
ndarray constructor:
ndarray An array object represents a multidimensional, homogeneous array of fixed-size items
class numpy. ndarray
An array object represents a multidimensional, homogeneous array of fixed-size items. An associated data type
bject describes the format of each element in the array (its byte-order, how many bytes it occupies in memory,
whether it is an integer, a floating point number, or something else, etc.
Arrays should be constructed using array, zeros or empty (refer to the See Also section below ). The
parameters given here refer to a low-level method (ndarray (..))for instantiating an array
For more information, refer to the numpy module and examine thethe methods and attributes of an arra
Parameters
(for the new method; see Notes below)
shape: tuple of ints
Shape of created array
Chapter 1. Array objects
Num Py Reference, Release 1.12.0.devo+e6593fb
dtype dat
Any object that can be interpreted as a numpy data type
buffer: object exposing buffe
Used to fill the array with data
ffset: int optional
Offset of array data in buffer
strides: tuple of ints, optional
Strides of data in memory
order:(C',“F”},o
Row-major(C-style)or column-major( Fortran-style)order
array
Construct an array.
ex。s
Create an array, each element of which is zero
pty
Create an array, but leave its allocated memory unchanged (i.e, it contains"garbage")
atype
Create a data-type
Notes
There are two modes of creating an array using new_:
1. f buffer is None, then only shape, dtype, and order are used
2. If buffer is an object exposing the buffer interface, then all key words are interpreted
N
nit method is needed because the array is fully initialized after the __new method
Examples
These examples illustrate the low-level ndarray constructor. Refer to the See Also section above for easier
ays of constructing an ndarray
First mode, buffer is none:
p. ndarray(she
(2, 2), dtype-float, order='E
array([[-1.13698227e+002;4.25087011e-303]
[2.88528414e-306;3.27025015e-309]])
#random
Second mode.
np. ndarray((2,), buffe
offset-np.int_()·it
slype=⊥nL)#a⊥CseL=1* iTerms⊥∠e,⊥,e,ski0⊥ irsL elemer
array([2, 31)
Attributes
1.1. The N-dimensional array( ndarray)
NumPy Reference, Release 1.12.0.dev0+e6593fb
data
Python buffer object pointing to the start of the array 's dale di
Same as self transpose(), except that self is returned if self. n
datype
Data-type of the array s elements
flags
nformation about the memory layout of the array
flat
A 1-d iterator over the array
⊥mag
The imaginary part of the array
rea⊥
The real part of the array
Number of elements in the array
itemsize Length of one array element in bytes
nbytes
Total bytes consumed by the elements of the array
ndim
Number of array dimensions
shape
Tuple of array dimensions
strides Tuple of bytes to step in each dimension when traversing an array
types
An object to simplify the interaction of the array with the ctypes module
base
Base object if memory is from some other object
ndarray.T
Same as self transpose(, except that self is returned if self ndim <2
Examples
>>>x=np. array([[1.,2.],[3.,4.]])
>>>又
array([[ 1., 2
4.1]
y([[1
>>>x=np. array([1.,2.,3.,4.])
array([ l
>>>又.T
array([ 1
4.])
darray data
Python buffer object pointing to the start of the arrays data
ndarray dtype
Data-type of the array's elements
Parameters
None
Returns
d: numpy dtype object
See also
numpy atype
xamples
array([[o, 1]
ype
dtype( int32)
Chapter 1. Array objects
(系统自动生成,下载前可以参看下载内容)
下载文件列表
相关说明
- 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
- 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度。
- 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
- 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
- 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
- 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.