n this chapter, we will discuss about NumPy – vsplit. This NumPy.vsplit is a special case of split() function where the axis is 1 indicating a vertical split regardless of the dimension of the input array. The following example makes this clear.
Example Of NumPy vsplit
import numpy as np a = np.arange(16).reshape(4,4) print 'First array:' print a print '\n' print 'Vertical splitting:' b = np.vsplit(a,2) print b
Its output would be as follows −
First array: [[ 0 1 2 3] [ 4 5 6 7] [ 8 9 10 11] [12 13 14 15]] Vertical splitting: [array([[0, 1, 2, 3], [4, 5, 6, 7]]), array([[ 8, 9, 10, 11], [12, 13, 14, 15]])]
Next Topic – Click Here
Pingback: NumPy Array Manipulation - Adglob Infosystem Pvt Ltd