NumPyhsplit函数

首页 / Numpy入门教程 / NumPyhsplit函数

numpy.hsplit是split()函数的特例,其中axis为1表示水平拆分,而与输入数组的维度无关。

import numpy as np 
a = np.arange(16).reshape(4,4) 

print 'First array:' 
print a 
print '\n'  

print 'Horizontal splitting:' 
b = np.hsplit(a,2) 
print b 
print '\n'

其输出如下-

链接:https://www.learnfk.comhttps://www.learnfk.com/numpy/numpy-hsplit.html

来源:LearnFk无涯教程网

First array:
[[ 0 1 2 3]
 [ 4 5 6 7]
 [ 8 9 10 11]
 [12 13 14 15]]

Horizontal splitting:                                                         
[array([[ 0,  1],                                                             
       [ 4,  5],                                                              
       [ 8,  9],                                                              
       [12, 13]]), array([[ 2,  3],                                           
       [ 6,  7],                                                              
       [10, 11],                                                              
       [14, 15]])] 

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

教程推荐

Rust 语言从入门到实战 -〔唐刚〕

现代C++20实战高手课 -〔卢誉声〕

超级访谈:对话张雪峰 -〔张雪峰〕

手把手带你写一门编程语言 -〔宫文学〕

讲好故事 -〔涵柏〕

体验设计案例课 -〔炒炒〕

MongoDB高手课 -〔唐建法(TJ)〕

JavaScript核心原理解析 -〔周爱民〕

移动端自动化测试实战 -〔思寒〕

好记忆不如烂笔头。留下您的足迹吧 :)