Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Python and arrays

Status
Not open for further replies.

barney75

Mechanical
Jan 22, 2007
58
0
0
IT
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
 
Replies continue below

Recommended for you

Hi DanStro
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
 
Status
Not open for further replies.
Back
Top