I need a help in python where if a sequence of month is missing as per user input then it will give the output rows as either equal too or nearest smallest numbers from Months in all VIN.
CurrentDf:
| VIN | Total Age | Months | Monthly Revenue |
|---|---|---|---|
| v1 | 10 | 00 | 1513 |
| v1 | 10 | 05 | 1108 |
| v1 | 10 | 07 | 4330 |
| v1 | 10 | 09 | 7121 |
| v2 | 08 | 01 | 1998 |
| v2 | 08 | 04 | 4997 |
| v2 | 08 | 05 | 8528 |
| v2 | 08 | 06 | 1783 |
| v2 | 08 | 07 | 9628 |
| v2 | 08 | 08 | 2082 |
Age = [int(x) for x in input('Please enter Months?= ').split(',')]
If UserInput: 6
outputDF:
| VIN | Total Age | Months | Monthly Revenue |
|---|---|---|---|
| v1 | 10 | 05 | 1108 |
| v2 | 08 | 06 | 1783 |