Example Analysis of Array superposition function in python
This article will explain in detail the example analysis of array superposition functions in python. The content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have some understanding of the relevant knowledge after reading this article.
1. Hstack represents horizontal overlay. For the stack to be successful, the rows must be consistent.
2. Vstack represents vertical superposition. If the overlay is successful, the columns must be consistent.
3. Concatenate manually specifies the direction of overlay.
Axis=0 represents vertical stack, axis=1 represents horizontal stack, and axis=None represents one-dimensional array stack.
Example
Import numpy as nph2 = np.random.randint (0Jing 10jue size = (3jue 1)) H2 # results:''array ([[4], [8], [2])''h3 = np.random.randint (0JE10 penny size = (3jue 4)) h3 # results:''array ([6, 9, 5, 0], [6, 1, 9, 4], [8, 8, 9] ])''h5 = np.random.randint (0Jing 10 scene size = (1)) h5 # result 'array ([[2, 3, 5]])''# 2. Horizontal stack h4 = np.hstack ([h2jinh3]) h4 # result:''array ([[4, 6, 9, 5, 0], [8, 6, 1, 9, 4], [2, 8, 8, 9, 8]))''# 3. Use concatenate for custom stitching np.concatenate ([h2jinh3], axis=1) # horizontal stitching result:''array ([[4, 6, 9, 5, 0], [8, 6, 1, 9, 4], [2, 8, 8, 9, 8]))''# 3. Use concatenate to customize the stack np.concatenate ([h2jinh3], axis=None) # into an one-dimensional array result:''array ([4, 8, 2, 6, 9, 5, 0, 6, 1, 9, 4, 8, 8, 9, 8])''# 3. Custom stacking np.concatenate ([h3jingh4], axis=0) # Longitudinal splicing results using concatenate array ([[6, 9, 5, 0], [6, 1, 9, 4], [8, 8, 9, 8], [2, 3, 5, 5]]) this is the end of the sample analysis of array stack functions in python I hope the above content can be of some help to you and learn more knowledge. If you think the article is good, you can share it for more people to see.