[SciPy-user] Numpy for Matlab users

Nils Wagner nwagner at mecha.uni-stuttgart.de
Wed Feb 15 11:00:49 CST 2006


Robert Kern wrote:
>Nils Wagner wrote:
>
>  
>>This might be straightforward if I want to remove the first or last row.
>>
>>a=a[1:,:]
>>a=a[:3,:]
>>
>>but how can I efficiently remove the second or third row w.r.t. to your
>>example ?
>>    
>
>Robert Cimrman gave you the answer.
>
>  
>>> a=rand(4,3)
>>> a
array([[ 0.91343331,  0.78947381,  0.39115252],
       [ 0.17682632,  0.75310694,  0.0081875 ],
       [ 0.82873565,  0.08136179,  0.46704486],
       [ 0.38479685,  0.54347342,  0.21294132]])
>>> a=a[(0,2,3),:]
>>> a
array([[ 0.91343331,  0.78947381,  0.39115252],
       [ 0.82873565,  0.08136179,  0.46704486],
       [ 0.38479685,  0.54347342,  0.21294132]])

But it might be easier to say what I would like to remove instead of
what I want to keep ...
 
Do you agree ?

Nils



More information about the SciPy-user mailing list