I have a df with 4 columns: ID, Value, UpperBound and LowerBound, like this:
ID | Value | UpperBound | LowerBound
1 23 NaN NaN
2 55 NaN NaN
3 87 NaN NaN
4 99 NaN NaN
5 NaN 50 5
6 NaN 5 1
7 NaN 95 50
8 NaN 99 95
And I want to convert the values in Value column to UpperBound and LowerBound according to the respective bounds (23 for example fits between 50-5). So that the output looks something like this:
ID | Value | UpperBound | LowerBound
1 NaN 50 5
2 NaN 95 50
3 NaN 95 50
4 NaN 99 95
5 NaN 50 5
6 NaN 5 1
7 NaN 95 50
8 NaN 99 95
The Value column will end up with only NaN values, so I can eliminate it later.
The UpperBound and LowerBound are the following:
1-5
5-50
50-95
95-99
Can someone help me create the necessary code to do this?
Thank you so much in advance!!