Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of Array superposition function in python

2025-04-12 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report