How to move first n elements to end of array in Python

1 Answer

0 votes
import numpy as np

arr = np.arange(10)

print(arr)

n = 3
arr = np.roll(arr, n * (-1))

print(arr)




'''
run:

[0 1 2 3 4 5 6 7 8 9]
[3 4 5 6 7 8 9 0 1 2]

'''

 



answered Feb 23, 2023 by avibootz
...