Skip to content

Instantly share code, notes, and snippets.

@AKuederle
Created February 11, 2015 10:50
Show Gist options
  • Save AKuederle/aa9aaaafe5d858854f70 to your computer and use it in GitHub Desktop.
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
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