3
I have an array and need to change the order of the lines.
array([[ 0, 1, 2, 3, 4],
[ 5, 6, 7, 8, 9],
[10, 11, 12, 13, 14],
[15, 16, 17, 18, 19],
[20, 21, 22, 23, 24]])
I need it like this:
array([[ 5, 6, 7, 8, 9],
[ 0, 1, 2, 3, 4],
[10, 11, 12, 13, 14],
[15, 16, 17, 18, 19],
[20, 21, 22, 23, 24]])
I tried to use the .reindex
but I didn’t succeed, what would be the best way to do that?
import numpy as np
arr = np.arange(25)
arr = arr.reshape(5,5)
print('array inicial:')
print(arr)
print('array com as linhas 0 e 1 trocadas entre si:')
Needed to do this using numpy library
If your program first creates the list and then inserts it into the array, it would be more interesting to deal with list.pop() before insertion.
– SakuraFreak