def bisect_df(df, v, col='variable_name_nd'):
    """Perform a binary search on a dataframe"""
    from math import log
    max_n = log(len(df)) / log(2) + 2
    low = 0
    high = len(df)
    mid = int((low + high) / 2)
    n = 0
    while True:
        e = df.iloc[mid]
        if v == e[col]:
            return e
        if v > e[col]:
            low = mid
        else:
            high = mid
        mid = int((low + high) / 2)
        if n > max_n:
            return None
        n += 1
    return None
