Learn how to deal with Numpy matrix dimensionality using np.reshape, np.newaxis and np.expand_dims, illustrated with Python code.



  • It is used to increase the dimension of the existing array. It uses the slicing operator to recreate the array.
  • The dimension is temporarily added at the position of np.newaxis in the array. ‘None’ can also be used in place of np.newaxis.


  • It is used to reshape the array to the desired layout.


  • It expands the shape of an array by inserting a new axis at the axis position in the expanded array shape

Let’s see some primary applications where above NumPy dimension handling operations come in handy:

#2020 jul tutorials #overviews #numpy

How to Handle Dimensions in NumPy
2.10 GEEK