In case, I want to transform a list of a column into a 3x3 array in numerical order:
lista =([[1],
[2],
[3],
[4],
[5],
[6],
[7],
[8],
[9]])
Being the expected result:
([[7 8 9]
[4 5 6]
[1 2 3]])
In case, I want to transform a list of a column into a 3x3 array in numerical order:
lista =([[1],
[2],
[3],
[4],
[5],
[6],
[7],
[8],
[9]])
Being the expected result:
([[7 8 9]
[4 5 6]
[1 2 3]])
Using numpy:
import numpy as np
lista = np.arange(1, 10).reshape(9, 1)
print(lista)
'''
array([[1],
[2],
[3],
[4],
[5],
[6],
[7],
[8],
[9]])
'''
Now we can do:
lista = lista.reshape(3, 3)[::-1] # forma-lo em 3 linhas e 3 colunas, e inverter
print(lista)
'''
array([[7, 8, 9],
[4, 5, 6],
[1, 2, 3]])
'''