numpy.expand_dims()

numpy.expand_dims

numpy.expand_dims(a, axis) [source]

Expand the shape of an array.

Insert a new axis, corresponding to a given position in the array shape.

Parameters:

a : array_like

Input array.

axis : int

Position (amongst axes) where new axis is to be inserted.

Returns:

res : nda