I want to search a dataframe to find a value correspond to index row and column value. However, I am struggling because the column header values are the upper bound of a range where the previous column header value is the lower bound ( but the uppper bound of its other neightbor column value).
I cannot find a way to match my input with the column corresponding to the lower bound of the range.
with an example it is very easy to see:
data_frame_test = pd.DataFrame({'location' : [1, 2, 'S'],
'200' : [342, 690, 103],
'1000' : [322, 120, 193],
'2000' : [249, 990, 403]})
data_frame_test = data_frame_test.set_index('location')
and what I want to do is this
location = 1
weight = 500
output = data_frame_test.iloc[1][??] #must be equal to 342
see, the column where weight must look into is 200, because it is in the range between ]200;1000[. I don't know what else to try to translate that into python code. Any help would be greatly appreciated.