日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
創(chuàng)新互聯(lián)Python教程:python數(shù)組分割的函數(shù)

1、hsplit,水平方向分割。

通過指定返回相同shape的array的數(shù)量,或者分割應(yīng)該發(fā)生之后的列來沿著其橫軸拆分。

2、vsplit,沿著垂直軸分割。

3、split/array_split,自定義分割,axis=1 水平分割,axis=0 垂直方向分割。

實(shí)例

# 4.分割-水平方向分割
h5 = np.random.randint(0,100,size=(6,4))
h5
'''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(h5,2) # 將h5水平分割等分兩個數(shù)組,被分割的列一定為指定分割數(shù)的倍數(shù)
'''[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(h5,[1,3])#將h5從下標(biāo)為1、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]])]
'''
# 5 分割-縱向分割
np.vsplit(h5,3)
'''
[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(h5,[1,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 分割-自定義分割
np.split(h5,2,axis=1) #橫向分割,按列分割
'''
[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(h5,3,axis=0)#縱向分割,按行分割
'''
[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]])]
'''

以上就是python數(shù)組分割的函數(shù),希望對大家有所幫助。更多Python學(xué)習(xí)指路:創(chuàng)新互聯(lián)python教程


標(biāo)題名稱:創(chuàng)新互聯(lián)Python教程:python數(shù)組分割的函數(shù)
分享路徑:http://www.5511xx.com/article/copecee.html