Python and arrays
Python and arrays
(OP)
Hy guys,
I need an help on how to manipulate arrays in python using the module Numeric or array.
Consider the following array a
a = reshape(arange(9),(3,3))
>>> print a
[[0 1 2]
[3 4 5]
[6 7 8]]
ok, now how is it possible (any command?) to add a new row let say [9,10,11] to the array a in order to get a new matrix a as follows:
[[0 1 2]
[3 4 5]
[6 7 8]
[9 10 11]]
I need to know it in order to assemble a matrix recursively inside a loop.
Thanks bye
I need an help on how to manipulate arrays in python using the module Numeric or array.
Consider the following array a
a = reshape(arange(9),(3,3))
>>> print a
[[0 1 2]
[3 4 5]
[6 7 8]]
ok, now how is it possible (any command?) to add a new row let say [9,10,11] to the array a in order to get a new matrix a as follows:
[[0 1 2]
[3 4 5]
[6 7 8]
[9 10 11]]
I need to know it in order to assemble a matrix recursively inside a loop.
Thanks bye





RE: Python and arrays
a.append([9,10,11])
HTH
Dan
RE: Python and arrays
thanks for your advice, but it doesn't work. As far as I know the append method is available in array module. I've imported the array module and tried your solution but it seems that a.append() require a float as input in brackets therefore u can not give [9,10,11]. As said previously I need to assemble an array in a loop in order to use slicing methods.
Any other advice will be appreciate.
Bye
Thanks