numpy中的split方法

numpy.array_split


注:切分array是按照从左至右的顺序切分,不是随机切分!

numpy. array_split ( ary, indices_or_sections, axis=0 ) [source]

Split an array into multiple sub-arrays.

Please refer to the split documentation. The only differencebetween these functions is that array_split allowsindices_or_sections to be an integer that does not equallydivide the axis.

See also

split
Split array into multiple sub-arrays of equal size.

Examples

>>>
>>> x = np.arange(8.0)
>>> np.array_split(x, 3)
    [array([ 0.,  1.,  2.]), array([ 3.,  4.,  5.]), array([ 6.,  7.])]
 
         

你可能感兴趣的:(Python)