numpy.roll()

numpy.roll

numpy.roll(a, shift, axis=None) [source]

Roll array elements along a given axis.

Elements that roll beyond the last position are re-introduced at the first.

Parameters:

a : array_like

Input array.

shift : int

The number of places by which elements are shifted.

axis : int, optional

The axis along which elements are shifted. By default, the array is flattened before shifting, after whic