numpy官方参考手册.pdf

所需积分/C币:39 2018-03-05 20:28:20 7.3MB PDF
124
收藏 收藏
举报

python中必须掌握的库之一 numpy官方参考手册.pdf numpy官方参考手册.pdf
CONTENTS Array objects 1. 1 The N-dimensional array (ndarray) 1.3 Data type objects(dt ype) “· ..110 1.4 Indexing 121 1.5 Standard array subclasses 125 1. 6 Masked arrays 250 1. 7 The Array Interface 433 2 Universal functions(ufunc) 439 2.1 Broadcasting 439 2.2 Output type determination 440 2.3 Use of internal buffers 440 2.4 Error handling 440 2.5 Casting Rules .443 2.6 func 445 2.7 Available ufuncs 452 3 Routines 457 3.1 Array creation routines 457 3.2 Array manipulation routines .488 3.3 Indexing routines “ 522 3.4 Data type routines 3.5 Input and output 55 3.6 Discrete Fourier Transform(numpy. fft) 579 3.7 Linear algebra (numpy linalg) 3.8 Random sampling(numpy. random 627 3.9 Sorting and searching 678 3.10 Logic functions 3.11 Binary operations 707 3. 12 Statistics 715 3. 13 Mathematical functions 735 3. 14 Functional programming 794 3.15 Polynomials 70 3.16 Financial functions 812 3.17 Set routi 820 3.18 Window functions 3. 19 Floating point error handling .836 3.20 Masked array operations 842 3.21N fic help functions 962 3.22 Miscellaneous routines 965 3.23 Test Support(numpy testing) 966 3.24 Assert 967 3.25 Mathematical functions with automatic domain (numpy. emath) 977 3.26 Matrix library(numpy matlib) ..,.,977 3.27 Optionally Scipy-accelerated routines(numpy dual) 977 3.28 Numarray compatibility(numpy numarray) ......978 3.29 Old Numeric compatibility(numpy ol numeric) 978 3.30 C-Types Foreign Function Interface(numpy. ctypeslib) 978 3.31 String operations 979 4 Packaging(numpy distutils) 1015 4.1 Modules in numpy distutils 1015 4.2 Building Installable C libraries 1026 4.3 Conversion of, src fles 1027 5 Numpy C·API 1029 5.1 Python Types and C-Structures ..,..,1029 5.2 System configuration .1043 5.3 Data Type API 1045 5.4 Array API 1047 5.5 FUnc API 1080 5.6 Generalized Universal Function API ..1085 5.7 Numpy core libraries 1087 6 Numpy internals 1091 6. 1 Numpy c Code explanations 1091 6.2 Internal organization of numpy arrays 1098 .3 Multidimensional Array Indexing Order Issues l099 7 Acknowledgements 1101 Bibliography 1103 Python Module Index 1109 Index 1111 Num Py Reference, Release 1.5.1 Release Date November 18.2010 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.5.1 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 exactly 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 data head data-type y apra 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 ofn 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 hich 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 3 NumPy Reference, Release 1.5.1 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 2x 3, composed of 4-byte integer elements: >>>x=np. array([1,;2,3],[4,5,6]],np.int32) >>>type(x) d shape (2,3 >>>xdtype (′int32′) The array can be indexed using Python container- like syntax >>>x[1,2] #i.c., the element of x in the *second* row, *third+ For example slicing can produce views of the array ([2,5]) [0]=9 this dlso changes Lhe corresponding element in x >>>y array(「9,51) array([[ [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 object 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 Hoating 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 array Parameters (for the new method; see Notes below) shape: tuple of ints Shape of created array dtype: data-type, optional Any object that can be interpreted as a numpy data type Chapter 1. Array objects Num Py Reference, Release 1.5.1 buffer: object exposing buffer interface, optional Used to fill the array with data offset: int, optional Offset of array data in buffer strides: tuple of ints, optional Strides of data in memory order C’,F}, optional Row-major or coluInn-najor order. See also: array Construct an array. ze。s Create an array each element of which is zero empt Create an array, but leave its allocated memory unchanged (i. e, it contains garbage") atype Create a data-ty 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 No_init method is needed because the array is fully initialized after the_ method Examples These examples illustrate the low-level ndarray constructor. Refer to the See Also section above for easier ways of constructing an ndarray First mode, buffer is No >> rp.ndarray(shape-(2, 2), dtype-float, order-F') array([[-1.13698227e+002 4.25087011e-303] 「2.88528414e-306,3.27025015e-30911) frandor p.ndarray((2,), buff offset=np. int_().itemsize, dtype=int)# offset =I*itemsize, i.e. skip first element array([2, 31) 1.1. The N-dimensional array( ndarray) NumPy Reference, Release 1.5.1 Attributes data atype Create a data type object flags flat imag(val) Return the imaginary part of the elements of the array real(val) Return the real part of the elements of the array size(al, axis] Return the number of elements along a given axis itemsize nbytes Base object for a dictionary for look-up with any alias for an array dtype. ndim(a) Return the number of dimensions of an array. shape(a) Return the shape of an array trides ctypes create and manipulate C data types in Python base class numpy dtype Create a data ty A numpy array is homogeneous, and contains elements described by a dtype object. a dtype object can be constructed from different combinations of fundamental numeric types Parameters 0 Object to be converted to a data type object align: bool, optional Add padding to the fields to match what a C compiler would output for a similar C- struct. Can be True only if obj is a dictionary or a comma-separated string copy: bool, optional Make a new copy of the data-type object. If False, the result may just be a reference uilt-in data-type object Examples Using array-scalar type: >>>np. d=ype(np int16) dtype(in-16′) Record. one field name fl. containing int 6 np.d-y9e([(′1′,np.inL16)]) dtype(「("f1′,<i2′)1) Record, one field named'fI,, in itself containing a record with one field >>>np.d=yoe([("f1′,[(f1′,np.int16)])]) slype([(1′,[(′1′,〃<i2′)])]) Record, two fields: the first field contains an unsigned int, the second an int 32 >>> np. d=ype([(fl, npuint),(f2 , np. int 32)1) dlype([('ll ⊥4′)]) Chapter 1. Array objects

...展开详情
试读 127P numpy官方参考手册.pdf
立即下载 低至0.43元/次 身份认证VIP会员低至7折
一个资源只可评论一次,评论内容不能少于5个字
上传资源赚积分or赚钱
    最新推荐
    numpy官方参考手册.pdf 39积分/C币 立即下载
    1/127
    numpy官方参考手册.pdf第1页
    numpy官方参考手册.pdf第2页
    numpy官方参考手册.pdf第3页
    numpy官方参考手册.pdf第4页
    numpy官方参考手册.pdf第5页
    numpy官方参考手册.pdf第6页
    numpy官方参考手册.pdf第7页
    numpy官方参考手册.pdf第8页
    numpy官方参考手册.pdf第9页
    numpy官方参考手册.pdf第10页
    numpy官方参考手册.pdf第11页
    numpy官方参考手册.pdf第12页
    numpy官方参考手册.pdf第13页
    numpy官方参考手册.pdf第14页
    numpy官方参考手册.pdf第15页
    numpy官方参考手册.pdf第16页
    numpy官方参考手册.pdf第17页
    numpy官方参考手册.pdf第18页
    numpy官方参考手册.pdf第19页
    numpy官方参考手册.pdf第20页

    试读结束, 可继续阅读

    39积分/C币 立即下载 >