1, the combination of the array
arr1 = np.arange(9).reshape((3, 3))
arr2 = np.array([[0, 1, 0], [1, 0, 1], [2, 1, 0]])
Create two-dimensional arrays
np.hstack = RES ((of arr1, arr2 is)) # level of splicing, splicing in a column direction RES = np.vstack ((of arr1, arr2 is)) # vertical stitching, stitching the row direction
Use hstack () method of splicing array level, using vStack () method of splicing the vertical array
# Axis 0 = 0 in the splicing dimension res = np.concatenate ((arr1, arr2), Axis = 0) # Axis = spliced. 1 in the first dimension res = np.concatenate ((arr1, arr2 ), axis = 1)
Use CONCATENATE () method sets the array on a specified dimension spliced, a multidimensional array, from the outside to the higher number of dimensions
2, an array of split
arr = np.arange(16).reshape((4, 4))
Create a two-dimensional array
np.hsplit = RES (ARR, 2) # horizontally split into two parts RES = np.vsplit (ARR, 2) # vertically split into two parts RES = np.vsplit (ARR,. 5) # error, not divisible, so can not be split
Use hsplit () method or vsplit () method of the array of horizontal or vertical split, the parameter 1 for the array to be split, parameter 2 for the split parts, you can be split into parts evenly distributed, otherwise it will error
= nothing np.split (arr, 2, axis = 0)
nothing = np.split (arr, 2, axis = 1)
Using the split () method to split the array, can be used axis dimension attributes specified array split