[Numpy-discussion] List of arrays

Wei Su taste_of_r@yahoo....
Mon May 11 16:33:10 CDT 2009


Hi, Francesc:
 
The codes do not work. Guess you forgot something there.
 
Thanks.
 
Wei Su

--- On Mon, 5/11/09, Francesc Alted <faltet@pytables.org> wrote:


From: Francesc Alted <faltet@pytables.org>
Subject: Re: [Numpy-discussion] List of arrays
To: "Discussion of Numerical Python" <numpy-discussion@scipy.org>
Date: Monday, May 11, 2009, 10:40 AM


A Monday 11 May 2009, Nils Wagner escrigué:
> Hi all,
>
> How can I convert a list of arrays into one array ?
>
> Nils
>
> >>> data
>
> [array([  40. ,  285.6,   45. ,  285.3,   50. ,  285.1,
>   55. ,  284.8]), array([  60. ,  284.5,   65. ,  282..8,
>   70. ,  281.1,   75. ,  280. ]), array([  80. ,  278..8,
>   85. ,  278.1,   90. ,  277.4,   95. ,  276.9]), array([
> 100. ,  276.3,  105. ,  276.1,  110. ,  275.9,  115. ,
>  275.7]), array([ 120. ,  275.5,  125. ,  275.2,  130. ,
>  274.8,  135. ,  274.5]), array([ 140. ,  274.1,  145. ,
>  273.7,  150. ,  273.2,  155. ,  272.7]), array([ 160. ,
>  272.2,  165. ,  272.1,  170. ,  272. ,  175. ,  271.8]),
> array([ 180. ,  271.6,  185. ,  271. ,  190. ,  270.3,
>  195. ,  269.5]), array([ 200. ,  268.5,  205. ,  267.4,
>  210. ,  266.1,  215. ,  263.5]), array([ 220. ,  260.1,
>  225. ,  256.1,  230. ,  249.9,  235. ,  239.3]), array([
> 238.7,  186.2,  240.,  160. ,  245. ,  119.7,  250. ,
>  111.3])]
>
> newdata=array([ 40. ,  285.6,   45. ,  285.3,   50. ,
>  285.1, 55. ,  284.8, 60. ,  284.5,   65. ,  282.8, ...,
>  111.3])

Try np.concatenate:

In [9]: a = np.arange(10)

In [10]: b = np.arange(10,20)

In [11]: np.concatenate(l)
Out[11]:
array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 
16, 17, 18, 19])

Hope that helps,

-- 
Francesc Alted

"One would expect people to feel threatened by the 'giant
brains or machines that think'.  In fact, the frightening
computer becomes less frightening if it is used only to
simulate a familiar noncomputer."

-- Edsger W. Dykstra
   "On the cruelty of really teaching computer science"
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20090511/87f1167c/attachment.html 


More information about the Numpy-discussion mailing list