Are you looking for np.roll-
np.roll(a,-1)
np.roll(a,1)
Run Example -
In [28]: a
Out[28]: array([ 1., 2., 3., 4.])
In [29]: np.roll(a,-1) # shifted left
Out[29]: array([ 2., 3., 4., 1.])
In [30]: np.roll(a,1) # shifted right
Out[30]: array([ 4., 1., 2., 3.])
If you want more changes, just go np.roll(a,-2)and np.roll(a,2)etc.
source
share