numpy.expand_dims() in Python

The numpy.expand_dims() function expands the shape of an array. It Inserts a new axis that appears at the axis position in the expanded array shape.



The numpy.expand_dims() function has two parameters which are as follows:

a : This parameter represents an input array.

axis: The axis parameter signifies the position in the expanded axes where the new axis is placed.


This function returns the output array wherein the number of dimensions is one greater than that of the input array.

Example 1


Pin It on Pinterest

Share This