Re: [Tutor] index of elements in numpy array

2012-09-14 Thread Oscar Benjamin
On 14 September 2012 11:05, eryksun wrote: > On Fri, Sep 14, 2012 at 4:36 AM, Bala subramanian > wrote: > > > > 10 # loop over each row > > 11 for i1, d1 in enumerate(b): > > 12 # each x in d1 - value in z corresponding to index of x in d1 > > 13 d1=[x-z[d1.index(x)] for x in d1] > >

Re: [Tutor] index of elements in numpy array

2012-09-14 Thread eryksun
On Fri, Sep 14, 2012 at 4:36 AM, Bala subramanian wrote: > > 10 # loop over each row > 11 for i1, d1 in enumerate(b): > 12 # each x in d1 - value in z corresponding to index of x in d1 > 13 d1=[x-z[d1.index(x)] for x in d1] > > If d1 is a simple list, i can fetch the index of its eleme

Re: [Tutor] index of elements in numpy array

2012-09-14 Thread Peter Otten
Bala subramanian wrote: > Thank you all for the answer. Below, i have pasted a sample code that > shows what i am intending to do. The code fails at line 13 as numpy > array dnt have a index attribute. > > 1 #!/usr/bin/env python > 2 import numpy as np > 3 > 4 a=np.array([1,2,3,4,5,6,7,8,

Re: [Tutor] index of elements in numpy array

2012-09-14 Thread Bala subramanian
Thank you all for the answer. Below, i have pasted a sample code that shows what i am intending to do. The code fails at line 13 as numpy array dnt have a index attribute. 1 #!/usr/bin/env python 2 import numpy as np 3 4 a=np.array([1,2,3,4,5,6,7,8,9,10,11,12]) 5 6 b=np.reshape(a,(3,4)

Re: [Tutor] index of elements in numpy array

2012-09-13 Thread Dave Angel
On 09/13/2012 04:16 PM, Bala subramanian wrote: > Friends, > I have a 2D matrix (a numpy array) and i am looping over each row in > the matrix. I would like to know how i can find the index of each > element in a while looping a row. Is there any function in numpy. > > Thanks > Perhaps you're aski

Re: [Tutor] index of elements in numpy array

2012-09-13 Thread akleider
> On 13 September 2012 21:16, Bala subramanian > wrote: > >> Friends, >> I have a 2D matrix (a numpy array) and i am looping over each row in >> the matrix. I would like to know how i can find the index of each >> element in a while looping a row. Is there any function in numpy. >> > > Your questio

Re: [Tutor] index of elements in numpy array

2012-09-13 Thread Oscar Benjamin
On 13 September 2012 21:16, Bala subramanian wrote: > Friends, > I have a 2D matrix (a numpy array) and i am looping over each row in > the matrix. I would like to know how i can find the index of each > element in a while looping a row. Is there any function in numpy. > Your question could mean

[Tutor] index of elements in numpy array

2012-09-13 Thread Bala subramanian
Friends, I have a 2D matrix (a numpy array) and i am looping over each row in the matrix. I would like to know how i can find the index of each element in a while looping a row. Is there any function in numpy. Thanks -- C. Balasubramanian ___ Tutor mai