In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Most people do not understand the knowledge points of this article, "what are the common methods of Python's NumPy library?", so the editor summarizes the following, detailed contents, clear steps, and a certain reference value. I hope you can get something after reading this article. Let's take a look at this article, "what are the common methods of Python's NumPy library?"
Preface
Python is a high-level, dynamic, multi-generic programming language. Python code often looks like pseudo code, so you can use a few lines of highly readable code to implement a very powerful idea.
Numpy is very simple. Numpy is a scientific computing library of Python, which provides the function of matrix operation, which is generally used with Scipy and matplotlib. In fact, list already provides a representation similar to a matrix, but numpy provides us with more functions.
First, introduce the numpy package:
Import numpy as np
First, the N-dimensional array object in numpy is called ndarrey, and some operations about it: the attribute of the 1.ndarry object: attribute description .ndim rank, that is, the number of axes or dimensions. the scale of the shaded object array, for the matrix, n rows, m columns, the number of sizendarray object elements, which is equal to the value of nimm in .shape. The element type of the dtypendarray object .itemsizendarray object. Element type of 2.ndarry in bytes (1): data type description bool Boolean type, True or Falseintc is the same as the int type in C language, generally an integer used for indexing by int32 or int64intp, an integer with the same length as ssize_t in C language, int32 or int64int8 byte length, value: [- 128,127] int1616 bit length integer, value: [- 32768, 32767] int3232 bit length integer Value: [- 231,231mur1] int6464-bit integer, value: [- 263,263] 2.ndarry element type (1): data type indicates bool Boolean type, True or Falseintc is the same as int type in C language, generally int32 or int64intp is an integer used for indexing, integer consistent with ssize_t, int32 or int64int8 byte length in C language, value: [- 128,127] int16-bit integer Value: [- 32768, 32767] int3332 bit length integer, value: [- 231,231 Mel 1] int6464 bit length integer, value: [- 263,263 Mel 1]
Element type of 3.ndarry (2):
Data type description: uint88 bit unsigned integer, value: [0255] uint1616 bit unsigned integer, value: [0,65535] uint3232 bit unsigned integer, value: [0,232mur1] uint6432 bit unsigned integer, value: [0,264mur1] float1616 bit semi-precision floating-point number: 1-bit sign bit, 5-bit index, 10-bit Mantissa float3232 bit semi-precision floating point number: 1-bit sign bit, 8-bit index 23-bit Mantissa float6464-bit semi-precision floating-point number: 1-bit sign bit, 11-bit index, 52-bit Mantissa complex64 complex type, real part and imaginary part are 32-bit floating-point complex128 complex type, real part and imaginary part are 64-bit floating-point 4.ndarry common function summary: function description np.arange (n) similar to range () function, returns ndarray type, elements from 0 to n-1np.ones (shape) generates an all-1 array based on shape Shape is a tuple type np.zeros (shape) to generate an all-zero array based on shape, and shape is a tuple type np.full (shape,val) to generate an array based on shape. Each element value is valnp.eye (n) to create a square naught unit matrix with a diagonal of 1. The rest is 0np.ones_like (a) generates an all-1 array based on the shape of the array a (a) generates an all-zero array based on the shape of the array a (np.full_like) generates an array based on the shape of the array a, each element value is valnp.linspace () fills the data equally according to the start-stop data The formation array np.concatenate () combines two or more numbers into a new array. Reshape (shape) does not change the array elements and returns an array in the shape of shape. The original array remains unchanged. Resize (shape) has the same function as .reshape (), but modifies the original array. Swapaxes (ax1,ax2) swapaxes replaces two dimensions of the array n dimensions. Flatten () reduces the dimension of the array and returns the folded one-dimensional array. The original array invariant np.abs (x) np.fabs (x) calculates the absolute value of each element of the array np.sqrt (x) calculates the square root of each element of the array np.square (x) calculates the square of each element of the array, log (x) np.log10 (x) np.log2 (x) calculates the natural logarithm of each element of the array, 10 base logarithm and 2 base logarithm np.ceil (x) np.floor (x) calculates the np.rint value or float value of each element of the array np.modf (x) returns the decimal and integer parts of each element of the array as two independent arrays np.cos (x) np.cosh (x) np.sin (x) np.sinh (x) np.tan (x) np.tanh (x) Calculate the ordinary and hyperbolic trigonometric functions of the elements of the array np.exp (x) calculate the exponential values of the elements of the array np.sign (x) calculate the symbolic values of the elements of the array 1 (+), 0,-1 (-) +-* / * * the corresponding operation of each element of the array np.maximum (XMagi y) np.fmax () np.minimum (XMago y) np.fmin () the maximum / minimum value calculation of the element level of np.mod (XMague y) the modular operation of the element level np.copysign (XMague y) assigns the symbols of the values of each element in the array y to the corresponding elements of the array x >
< >=
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 232
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.