'Numpy - Reshape a vector by columns
I'm quite new to numpy. Maybe an easy question but.. I have the following vector:
x = array([0., 1., 2., 3., 4., 5., 6., 7., 8.])
Using both
y=np.reshape(x, (3,3)) and y=np.array_split(x, 3)
I get the following 3*3 array:
[array([0., 1., 2.]),
array([3., 4., 5.]),
array([6., 7., 8.])]
While I'm looking for the opposite:
[array([0., 3., 6.]),
array([1., 4., 7.]),
array([2., 5., 8.])]
TIA Regards, Roberto
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
