I know if I do m = np.arange(1, 10), I'll get a matrix with values from 1 to 9 going across the rows. Is there a similar function to do this with values from 1 to 9 that go down the columns? i.e.,
1 4 7
2 5 8
3 6 9
I know if I do m = np.arange(1, 10), I'll get a matrix with values from 1 to 9 going across the rows. Is there a similar function to do this with values from 1 to 9 that go down the columns? i.e.,
1 4 7
2 5 8
3 6 9
You can use the reshape function from numpy
np.arange(1, 10).reshape(3,3,order='F')
array([[1, 4, 7],
[2, 5, 8],
[3, 6, 9]])
One of the ways to make your matrix column major is using reshape.
np.reshape(m, (3, 3), order='F')
More informations: https://numpy.org/doc/stable/reference/generated/numpy.reshape.html