how to get the maximum value from a specific portion of a array in python -


i have specific scenario need scan specific portion of array maximum value of portion , return position of value regards entire array. example

 searcharray = [10,20,30,40,50,60,100,80,90,110] 

i want scan max value in portion 3 8, (40,50,60,100,80,90)

and return location of value.

so in case max value 100 , location 6

is there way using python alone or oy numpy

first slice list , use index on max function:

searcharray = [10,20,30,40,50,60,100,80,90,110] slicedarray = searcharray[3:9] print slicedarray.index(max(slicedarray))+3 

this returns index of sliced array, plus added beginslice


Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -