Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > index of an element in a numarray array

Reply
Thread Tools

index of an element in a numarray array

 
 
avharut@gmail.com
Guest
Posts: n/a
 
      05-12-2006
hello everyone!
sorry to disturb you with this, but i really cant find anything
suitable about the topic in the numarray documentation.
how can i find in an efficient way the index of the last occurrence of
a given element in a numarray array?
many thanks in advance!

 
Reply With Quote
 
 
 
 
rory.brandybuck@gmail.com
Guest
Posts: n/a
 
      05-12-2006

wrote:
> how can i find in an efficient way the index of the last occurrence of
> a given element in a numarray array?


Something like that:
>>> where(arange(100) == 10)

(array([10]),)
>>> _[-1][-1]

10

Or:
>>> your_array = arange(10)
>>> value = 3
>>> indices = where(your_array == value)
>>> last_index = indices[0][-1]
>>> print last_index


 
Reply With Quote
 
 
 
 
avharut@gmail.com
Guest
Posts: n/a
 
      05-12-2006
thanks alot!!

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Making an array wrap, where last index + 1 = first index Shawn W_ Ruby 5 09-16-2009 02:45 PM
sorting index-15, index-9, index-110 "the human way"? Tomasz Chmielewski Perl Misc 4 03-04-2008 05:01 PM
how to Update/insert an xml element's text----> (<element>text</element>) HANM XML 2 01-29-2008 03:31 PM
NumArray array-indexing Michael Drumheller Python 6 08-16-2004 02:39 PM
Easiest way to *add a column* to a 2d matrix/array in numarray??? Christian Seberino Python 4 04-27-2004 08:08 PM



Advertisments