def index_nearest ( array , value ) : idx = ( np . abs ( array - value ) ) . argmin ( ) return idx
python nearest value in a list
Finds index of nearest value in array . Args : array : numpy array value : Returns : int http : // stackoverflow . com / questions / 2566412 / find - nearest - value - in - numpy - array
def index_nearest(array, value):
    """
    Finds index of nearest value in array.

    Args:
        array: numpy array
        value:

    Returns:
        int

    http://stackoverflow.com/questions/2566412/find-nearest-value-in-numpy-array
    """
    idx = (np.abs(array-value)).argmin()
    return idx