np.hstack(),numpy.hstack()

 

np.hstack将参数元组的元素数组按水平方向进行叠加

import numpy as np
 
arr1 = [1,2,3]
arr2 = [4,5]
arr3 = [6,7]
res = np.hstack((arr1, arr2,arr3)) 
print (res)
 
 
#
[1 2 3 4 5 6 7]

import numpy as np
 
arr1 = np.array([[1,3], [2,4] ])
arr2 = np.array([[1,4], [2,6] ])
res = np.hstack((arr1, arr2))
 
print (res)
 
#
[[1 3 1 4]
 [2 4 2 6]]

 

posted on 2022-09-22 14:32  lmqljt  阅读(50)  评论(0编辑  收藏  举报

导航