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