numpy.split() in Python

The numpy.split() function splits an array into multiple sub-arrays.



ary: This parameter represents the Array to be divided into sub-arrays.

indices_or_sections : This parameter represents an int or an 1-D array. If indices_or_sections is an integer, N, the array will be divided into N equal arrays along axis. If such a split is not possible, an error is raised.

axis: This parameter represents an axis along which the array is split. It is an optional parameter which takes int values, and by default, it is 0.


This function returns a list of sub-arrays.


This function raises a ValueError if the parameter ‘indices_or_sections’ is given as an integer, but a split does not result in equal division.

Example 1


Pin It on Pinterest

Share This