numpy.split(ary, indices_or_sections, axis=0)[source]
Split an array into multiple sub-arrays.
Parameters: |
ary : ndarray Array to be divided into sub-arrays. indices_or_sections : int or 1-D array If If
If an index exceeds the dimension of the array along axis : int, optional The axis along which to split, default is 0. |
---|---|
Returns: |
sub-arrays : list of ndarrays A list of sub-arrays. |
Raises: |
ValueError If |
See also
array_split
hsplit
vsplit
dsplit
concatenate
stack
hstack
vstack
dstack
>>> x = np.arange(9.0) >>> np.split(x, 3) [array([ 0., 1., 2.]), array([ 3., 4., 5.]), array([ 6., 7., 8.])]
>>> x = np.arange(8.0) >>> np.split(x, [3, 5, 6, 10]) [array([ 0., 1., 2.]), array([ 3., 4.]), array([ 5.]), array([ 6., 7.]), array([], dtype=float64)]
© 2008–2016 NumPy Developers
Licensed under the NumPy License.
https://docs.scipy.org/doc/numpy-1.11.0/reference/generated/numpy.split.html