Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the functions of python array segmentation

Shulou Source: shulou.com Published: 2022-06-03 16:09:14 10月31日 Update

This article mainly introduces what are the functions of python array segmentation, which are introduced in great detail and have certain reference value. Friends who are interested must finish reading them.

1. Hsplit, horizontal segmentation.

Split along its horizontal axis by specifying the number of array that returns the same shape, or the column after the split should have occurred.

2. Vsplit, split along the vertical axis.

3. Split/array_split, custom segmentation, axis=1 horizontal segmentation, axis=0 vertical segmentation.

Example

# 4. Segmentation-horizontal Segmentation h6 = np.random.randint (0Jing 100st size = (6je 4)) h6'''array ([[13,7,29,65], [57,50,79,12], [9,16,82,86], [97,62,43,92], [66,21,78,34], [95,33,51] 63]])''np.hsplit (h6Jing 2) # divide h6 horizontally into two arrays The column to be split must be a multiple of the specified partition [array ([[13,7], [57,50], [9,16], [97,62], [66,21], [95,33]]), array ([[29,65], [79,12], [82,86], [43,92], [78,34]) [51, 63])]]''np.hsplit (h6, [1d3]) # split h6 horizontally from subscript 1 and 3 [array ([[13], [57], [9], [97], [66], [95]]), array ([[7,29], [50,79], [16,82], [62]) 43], [21, 78], [33, 51]), array ([[65], [12], [86], [92], [34], [63])] [array ([[13, 7, 29, 65], [57, 50, 79, 12]), array ([9]) 16, 82, 86], [97, 62, 43, 92]), array ([[66, 21, 78, 34], [95, 33, 51, 63])]''np.vsplit (h6, [1jue 2])' [array ([13, 7, 29, 65]), array ([57, 50, 79, 12]), array ([9, 16, 82, 86], [97, 62, 43, 92]) [66, 21, 78, 34], [95, 33, 51, 63])]]''# 6 Segmentation-Custom Segmentation np.split (h6Magne2) # horizontal Segmentation Split''by column [array ([[13, 7], [57, 50], [9, 16], [97, 62], [66, 21], [95, 33]), array ([[29, 65], [79, 12], [82, 86], [43, 92], [78, 34], [51]) 63]])]''np.split (h6p3)) # Vertical split Segmentation by line''[array ([[13, 7, 29, 65], [57, 50, 79, 12]]), array ([[9, 16, 82, 86], [97, 62, 43, 92]]), array ([[66, 21, 78, 34], [95, 33, 51, 63]])] all the contents of the article "what are the functions of python array segmentation" Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Horizontal array direction function content article vertical same subscript two value multiple interest place example boy partner quantity more horizontal Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Linux MySQL Shulou Tech Info MariaDB