clean way prepend an element to a numpy array

Ben Finney ben+python at benfinney.id.au
Tue Jul 21 00:13:55 EDT 2009


bdb112 <boyd.blackwell at gmail.com> writes:

> If I want to add an element at the beginning of an array, it seems
> like I must make a list, insert in place, then make an array again.

The NumPy ‘ndarray’ type (which is what you get by default from the
‘array’ factory function) is a far more complex type than (and is not
derived from) the Python list.

For manipulating them, you'll want to study the NumPy documentation
<URL:http://docs.scipy.org/doc/numpy/reference/arrays.ndarray.html>.

-- 
 \     “Are you pondering what I'm pondering?” “I think so, Brain, but |
  `\        I don't think Kay Ballard's in the union.” —_Pinky and The |
_o__)                                                           Brain_ |
Ben Finney



More information about the Python-list mailing list