Created
February 11, 2015 10:50
-
-
Save AKuederle/aa9aaaafe5d858854f70 to your computer and use it in GitHub Desktop.
simple Python function to find the index of an array, which corrosponding value is nearest to a given float
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def find_nearest(array, value): | |
return (np.abs(array - value)).argmin() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment