numpy arrays

Heli hemla21 at gmail.com
Wed Mar 23 06:47:27 EDT 2016


On Wednesday, March 23, 2016 at 11:07:27 AM UTC+1, Heli 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]]
> 
> In general I would need to retrieve every nth element of the interior arrays in to single arrays. I know I can loop over and do this, but I have really big arrays and I need the fastest way to do this. 
> 
> Thanks for your help,

Thanks a lot everybody, 

Transposing is exactly what I want. I just was not sure if that would work on internal arrays of a 2D array. Problem solved thanks everyone.



More information about the Python-list mailing list