Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

find the closest smaller value in an array python

>>> # the smallest element of myArr greater than myNumber
>>> myArr[myArr > myNumber].min()  
44

>>> # the largest element of myArr less than myNumber
>>> myArr[myArr < myNumber].max()
4
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #find #closest #smaller #array #python
ADD COMMENT
Topic
Name
3+4 =