This is data from: Python for Data analysis, Chapter 4
1. NumPy Introduction
The numpy,numerical python abbreviation is the basic package used for scientific computing and data analysis. For data analysts, focus on the following points:
A:fast vectorized Arrya Operations for data munging and cleaning (data analysis and cleaning), subsetting and filtering (and filtering), transformation And any other kind of computations.
B:coomn array algortihsm like sorting, unique, and set operations
C:efficient descriptive statistics and aggregating/summarizing data
D:data Alignment (data tuning) and relational data manipulations for merging (merge) and joining together heterogeneous Data sets (heterogeneous number Data set)
E:expressing conditional logic as arry expressions instead of loops with if-elif-else branches access Ndarray faster
F:group-wise (group) data manipulations
One of the most commonly used functions of numpy is a and e, mainly as a container for transmitting data, and for comparing relational data or chart datasets, the most common is pandas.
2. NumPy array: NumPy Ndarray
2.1
Ndarray:n-dimensional Array. The numpy array is a multidimensional array object that contains the actual data and the metadata (tuple) that describes the data.
These tuples are typically called to get actual data
Remember to write down two points:
The elements of a multidimensional array of the same numpy are of the same type .
An element table that is indexed by a positive integer tuple (tuple) (usually the element is a number).
In NumPy the dimension (dimensions) is called an axis (axes), such as a three-dimensional matrix, and each dimension is an axis.
The number of axes, that is, the dimension of the array is called rank. such as three-dimensional matrix, rank 3, two-dimensional matrix, rank is 2.
A dimension is represented by an integer tuple, such as a two-dimensional general (2,3), which represents a matrix of 2 rows and 3 columns, the length of the tuple is 2, the first dimension is 2, and the second dimension is a length of 3.
2.2
First: Import NumPy as Ynp
2.2.1: Creating Ndarray:array function
NumPy provides a arrange function that returns an array of arrays instead of a list
Np.arrange (+). Reshape ((8,4)) generate a 8*4 matrix of 0-31
2.2.2: Base index (indexing) and slicing
ARR[N:M]: Intercept the value from nth to the bottom of the m-1 bit
It is important to note that array slice is a mapping of the original data, and any operations performed on it will be reflected on the original data. You can say that the original value is preserved with the copy () function.
2.2.2: Common indexing
Np.ix_ function: You can convert two one-dimensional integer arrays into an index combination to get all the values in this matrix combination
The above is the tune-up (1,0), (1,3), (max), (5,0), (5,3), (5,1), (7,0), (7,3), (7,1) a total of 9 values
2.3 Common functions
2.3.1: Math class
including Sqrt,exp,abs,add,subtract, etc.
Np.mean ()
Np.sum ()
Axis parameter: Axis=1 means that by row, axis=0 represents the column
2.3.2: sorting arrangement, unique
Functions: Sort ()
One of the most commonly used combinatorial logic (set logic) operations in NumPy is the unique () function, which removes multiple occurrences of a sequence of values and returns the form Arra
2.3.3: Generating random numbers
Np.random.normal (size=) generates 4*4 matrices arranged in a normal distribution
NP.RANDOM.RANDN (5,4) generates 5*4 matrices, arranged in normal distribution, with a mean of 0 and a standard deviation of 1.
Note: Although this is a basic summary, there is no guarantee that the understanding is all correct. With the multiple use of different functions, if there is a new experience, I will be back in time to update.
Python data processing: NumPy Basics