numpy arrays

Simon Ward simon+python at bleah.co.uk
Wed Mar 23 06:47:47 EDT 2016



On 23 March 2016 10:06:56 GMT+00:00, Heli <hemla21 at gmail.com> wrote:
>Hi, 
>
>I have a 2D numpy array like this:
>
>[[1,2,3,4],
> [1,2,3,4], 
> [1,2,3,4]
> [1,2,3,4]]
>
>Is there any fast way to convert this array to 
>
>[[1,1,1,1],
> [2,2,2,2]
> [3,3,3,3]
> [4,4,4,4]]

Use the transpose() method:
http://docs.scipy.org/doc/numpy-1.10.0/reference/generated/numpy.ndarray.transpose.html

Simon
-- 
Sent from Kaiten Mail. Please excuse my brevity.



More information about the Python-list mailing list