Python Basic Data Processing (Numpy) parsing

List to mat

X= [] The data is in list format. Performing matrix transformation requires np. mat() to perform a forced transformation.

Data Generation

Sequence generation: np.arange(0, 10,0.1) generates 0-10 data with an interval of 0.1 between each generated data.

Trigonometric function: np.sin(x).

Basic matrix: np.zeros(9) generates 9 one-dimensional matrices with 0, while np.zeros((1,2)) defaults to generating matrices with1 * 2 elements all 0.

The same goes for np.ones() np.eye().

Data Insertion

X = np.insert(X,0,values=[1],axis=1) inserts value 1 in the first column of the X matrix.

np.row_stack((a, [8,9])) inserts new elements and rows into the matrix.

Insert np.column_stack((a, [8,9])) column.

Copy the np.tile(a) matrix in all directions.

Matrix concatenation:

Column concatenation of two matrices in np.vstack(a,b). Np. hstack (a, b) performs row concatenation on two matrices--- Only two matrices can be concatenated.

np.stack(a,b,axis = 0 ); At 0, it is concatenated in rows, and at 1, it is concatenated in columns.

np.concatenate((a,b), axis = 1) Merge by Row.

Matrix operation:

Matrix multiplication: A * B/ numpy.matmul().

Matrix transpose: np.transpose() / A.T.

Matrix inverse: np.linalg.inv(a) / A.I.

Opening: np.sqrt() .

Multiply each element of the matrix by 2 A**2.

Dot product: np.dot(a,b).

Determinant: numpy.linalg.det().

Solution of linear equation system: numpy.linalg.solve().

Norm:

np.linalg.norm(x, ord=None, axis=None, keepdims=False).

Traversing matrix elements:

A [0,0] obtains the elements in the first row and column of A, and A [0] obtains the elements in the first row.

A [0:3,1:4] Slice operation to obtain elements from the first row to the fourth row, and from the first column to the fourth column.

Logical operations:

np.all(): returns true if all parentheses are true, and false if one of them is false.

np.any() : returns false if all parentheses are false, and true if one of them is true.

Statistical operations:

Statistical indicator functions: min, max, mean, media, var, std.

Np. function name darray. method name axis parameter: axis= 0 represents the column, axis; Index function representing the maximum and minimum values of rows:

Np.argmax (arr, axis=).

Np.argmin (arr, axis=).