[SciPy-user] appending rows to an array

Samuel GARCIA sgarcia at olfac.univ-lyon1.fr
Wed Oct 19 12:10:58 EDT 2005


the function is : concatenate

but more quickly :

for row concatenate :
In [14]: r_[array([[1,2,3], [4,5,6]]), array([[7,8,9]]) ]
Out[14]:
array([[1, 2, 3],
       [4, 5, 6],
       [7, 8, 9]])

for columns concatenate :
In [22]: c_[array([[1,2,3], [4,5,6]]), array([[1],[2]]) ]
Out[22]:
array([[1, 2, 3, 1],
       [4, 5, 6, 2]])







Ramon Crehuet a écrit :

>Dear all,
>    I need to append rows to an array (many times). For example:
>array([[1,2,3], [4,5,6]]) and array([7,8,9])
>should give:
>array([[1,2,3], [4,5,6],[7,8,9]])
>
>I know I can do this using the tolist method to transform the arrays to 
>lists, use append and then transform back to array, but is there a more 
>efficient way to do that? I read the manual and found concatenate but I 
>can't figure out how to use it...
>Thanks in advance,
>Ramon
>
>
>
>_______________________________________________
>SciPy-user mailing list
>SciPy-user at scipy.net
>http://www.scipy.net/mailman/listinfo/scipy-user
>  
>

-- 
Samuel GARCIA
CNRS - UMR5020
Universite Claude Bernard LYON 1
Laboratoire des Neurosciences et Systemes Sensoriels
50, avenue Tony Garnier
69366 LYON Cedex 07
04 37 28 74 64




More information about the SciPy-User mailing list