[SciPy-user] array manipulation

fred fredmfp@gmail....
Wed Nov 19 01:53:29 CST 2008


Robert Kern a écrit :
> On Wed, Nov 19, 2008 at 01:32, Nils Wagner <nwagner@iam.uni-stuttgart.de> wrote:
>> Hi all,
>>
>> How can I insert a row/column in an existing array ?
> 
> You can't.
And numpy.insert?

Return a new array with values inserted along the given axis
     before the given indices

     If axis is None, then ravel the array first.

     The obj argument can be an integer, a slice, or a sequence of
     integers.

     Examples
     --------
     >>> a = array([[1,2,3],
     ...            [4,5,6],
     ...            [7,8,9]])

     >>> insert(a, [1,2], [[4],[5]], axis=0)
     array([[1, 2, 3],
            [4, 4, 4],
            [4, 5, 6],
            [5, 5, 5],
            [7, 8, 9]])

Cheers,

-- 
Fred


More information about the SciPy-user mailing list