For splitting the 2d array,you can use two specific functions which helps in splitting the NumPy arrays row wise and column wise which are split and hsplit respectively .
1. split function is used for Row wise splitting.
2. hsplit function is used for Column wise splitting .
The simplest way of splitting NumPy arrays can be done on their dimension. A 3 * 4 array can easily be broken into 3 sets of lists for Rows and 4 set of lists using Columns. Here is how we can do the same :
import numpy as np
arr = np.array([[1,2,3,4],
# Displays (3,4)
#Split Row Wise
#Splitted as --> [1,2,3,4] | [5,6,7,8] | [9,10,11,12]
#Split Column Wise
#Splitted as --> [1,5,9] | [2,6,10] | [3,7,11] | [4,8,12]
This should work.
To know more, It's recommended to join our Python Training in Chennai today.