index of an element in a numarray array

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • avharut@gmail.com

    #1

    index of an element in a numarray array

    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!

  • rory.brandybuck@gmail.com

    #2
    Re: index of an element in a numarray array


    avharut@gmail.c om wrote:[color=blue]
    > how can i find in an efficient way the index of the last occurrence of
    > a given element in a numarray array?[/color]

    Something like that:[color=blue][color=green][color=darkred]
    >>> where(arange(10 0) == 10)[/color][/color][/color]
    (array([10]),)[color=blue][color=green][color=darkred]
    >>> _[-1][-1][/color][/color][/color]
    10

    Or:[color=blue][color=green][color=darkred]
    >>> your_array = arange(10)
    >>> value = 3
    >>> indices = where(your_arra y == value)
    >>> last_index = indices[0][-1]
    >>> print last_index[/color][/color][/color]

    Comment

    • avharut@gmail.com

      #3
      Re: index of an element in a numarray array

      thanks alot!!

      Comment

      Working...