I have a DataFrame like this:
| start_day | end_day | value |
|---|---|---|
| 1 | 4 | 1 |
| 1 | 6 | 2 |
| 1 | 8 | 3 |
I now want to generate a new DataFrame, where for each day (1-8) the value is determined by taking the value of the row where day is in [start_day, end_day] and the duration (end_day - start_day) is minimal. Eg:
| day | value |
|---|---|
| 1 | 1 |
| 2 | 1 |
| 3 | 1 |
| 4 | 1 |
| 5 | 2 |
| 6 | 2 |
| 7 | 3 |
| 8 | 3 |
Is there a way to do this without iterating through all the days and computing the value?