[Pythoneers] numpy array transformations

Michael Hartl hartl at mpe.mpg.de
Tue Feb 10 11:54:17 CET 2015


And another one (btw, do you really want empty arrays?):

import numpy as np
a = np.arange(140)
b = np.arange(140)
d = np.array((a,b)).transpose()


On 2015-02-10 11:51, Philipp Plewa wrote:
> Here are two suggestions:
>
> np.vstack((a,b)).T
>
> np.dstack((a,b))[0]
>
> Cheers,
> Philipp
>
>
>> On 10.02.2015, at 11:39, Leonard Burtscher <burtscher at mpe.mpg.de> wrote:
>>
>> Hi pythoneers,
>>
>> Let me try this list with a simple question: I have two numpy ndarrays (a,b), each of size (140,1), and would like to make them a single array of size (140,2).
>>
>> I can do this with
>> import numpy as np
>> a=np.arange(140,1)
>> b=np.arange(140,1)
>>
>> c=np.concatenate((a,b))
>> d=c.reshape(140,2)
>>
>> ...but I'm sure there's a shorter way to that. Does anyone know how?
>>
>> Thanks and cheers,
>> Leo
>>
>>
>> _______________________________________________
>> Pythoneers mailing list
>> Pythoneers at lists.mpe.mpg.de
>> https://lists.mpe.mpg.de/cgi-bin/mailman/listinfo/pythoneers
>
>
> _______________________________________________
> Pythoneers mailing list
> Pythoneers at lists.mpe.mpg.de
> https://lists.mpe.mpg.de/cgi-bin/mailman/listinfo/pythoneers
>


-- 
Dr. Michael Hartl
Max Planck Institute for Extraterrestrial Physics | Giessenbachstrasse | 85748 Garching | Germany
Tel: (+49 89) 30000-3282 | Fax: (+49 89) 30000-3569
hartl at mpe.mpg.de | http://www.mpe.mpg.de/ir



More information about the Pythoneers mailing list