Hi,

This works, but reshape doesn't move data around. What happens is that the
data is flattened and then reshaped. If your 5 is not supposed to move, you
should create a 2,5,4 array and then copy the two slices by hand, or use
transpose (make it 5,4,2 and then transpose to 2,5,4=.

Matthieu

Le 10 juil. 2017 11:40 AM, <paul.carr...@free.fr> a écrit :

> Dear All
>
> I'm looking in a way to reshape a 2D matrix into a 3D one ; in my example
> I want to *move the columns from the 4th to the 8th in the 2nd plane*  (3rd
> dimension i guess)
>
> a =  np.random.rand(5,8); print(a)
>
> I tried
>
> a = p.reshape(d, (2,5,4), ) but it is not what I'm expecting
>
>
> Nota : it looks like the following task (while I want to split it in 2
> levels and not in 4), but I've not understood at all
>
> https://stackoverflow.com/questions/31686989/numpy-
> reshape-and-partition-2d-array-to-3d
>
>
> Thanks for your support
>
>
> Paul
>
>
>
>
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@python.org
> https://mail.python.org/mailman/listinfo/numpy-discussion
>
>
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion

Reply via email to