I have the following dataframe, and a variable equal to 20. I need to find where this variable is in col2 (here between 10 and 50) and output the lowest value in col1, here would be 2. Another example would be to have a variable equal to 51 and the correct output of col1 would be 3.
I could do it with an if formula but I am hopping for a better solution for larger datasets.
d = {'col1': [1, 2, 3, 4, 5], 'col2': [0, 10, 50, 60, 70]}
df = pd.DataFrame(data=d)
