×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Python and arrays

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

RE: Python and arrays

I think it should just be:

a.append([9,10,11])

HTH
Dan

RE: Python and arrays

(OP)
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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources