On 13 September 2012 21:16, Bala subramanian <bala.biophys...@gmail.com>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 several things. Could you post a small piece of
example code and clarify what it is you're unable to do?

Here's an example that loops over all elements of a 2D Matrix:

>>> import numpy
>>> M = numpy.array([[1, 1], [2, 3], [5, 8]])
>>> M
array([[1, 1],
       [2, 3],
       [5, 8]])
>>> numrows, numcols = M.shape
>>> for i in range(numrows):
...   for j in range(numcols):
...      print M[i, j]
...
1
1
2
3
5
8

Oscar
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to