Python Numpy split()

Python Numpy split()

NumPy generally stands for Numerical Python and it is a general purpose array processing always provides a high performance multidimensional array object.Numpy is usually for creating array of n dimensions.

Method Name :numpy.split(ary, indices_or_sections, axis)
Description : The function splits the array into multiple subarrays along a specified axis. These arrays are especially viewed as in ary.

In this article, I will tell you about the parameter and description
Parameter Name: ary
Description :ndarray
Input array to be split into sub-arrays.

Parameter Name: indices_or_sections
Description :int or 1-D array
It can be an integer, N, showing the number of equal sized subarrays to be formed from the input array along an axis. If this parameter is a 1-D array of sorted integers, the entries indicate the points at which a new subarray is to be created along the axis. If such a split is not happening, an error is being raised.
For example, [5,6] for axis=0 results
ary[5:6] ary[6:]
If an index has exceeded the dimension of the array along an axis, an empty sub-array is returned at that time.

Parameter Name: axis
Description :int
The axis along which we want to split by default value is being 0.

Return :A list of sub-arrays is showing into ary.

The first step would be to give syntax
numpy.split(ary, indices_or_sections, axis)

Example :
Code :
import numpy as np a = np.arange(15) print ('First array:') print (a ) print ('\n') print ('Split the array in 3 equal-sized subarrays:' ) b = np.split(a,5) print (b ) print ('\n') print( 'Split the array at positions indicated in 1-D array:' ) b = np.split(a,[4,9]) print( b )