Numpy common operations

1. Numpy traversal element processing function: np.apply_along_axis(np.mean(),axis=0,arr=a)​

The first parameter is the operation function, which can be a custom function, the second parameter axis=0 is column-wise operation, 1 is row-wise operation, and the third parameter is the name of the operation array​

2. Change the shape of the array a.reshape(3,4)​

3. Array transpose transpose()

4. Array combination vertical insertion np.vstack(a,b) horizontal insertion np.hstack(a,b) multiple array combination column_stock(a,b,c) row_stock(a,b,c)

5. Array segmentation Horizontal segmentation hsplit(a,2) Vertical segmentation vsplit(a,2) Divide the array into two parts, unequal segmentation split(a,[1,5,10],axis=1 ); where the first parameter is an array, the second parameter is the split position, [1,5,10] means split into four pieces, 1 is the first piece, 2:5 is the second piece..., the first The three parameters 1 is to split by column, 0 is to split by row, that is, 1 column is the first block, 2:5 is the second block...

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324643341&siteId=291194637