M = np.reshape(np.arange(16),(4,4)) np.array([np.roll(M,(i,j),(0,1)) for i in [1,0,-1] for j in [1,0,-1]])