While working over NumPy arrays, it is possible that you would have to manipulate data to obtain the desired results. NumPy arrays provide you the feature of changing the shape, combining and splitting arrays, etc.
Stacking is done using the np.hstack()
and np.vstack()
methods. For horizontal stacking, the number of rows should be the same, while for vertical stacking, the number of columns should be the same. Let’s hear more about it from Vaidehi.
Similar to stacking, another manipulation that is performed over arrays is reshaping. It is done using the reshape()
function. It helps you to change the dimensions of the existing arrays.