I want to increase the length of a list in python, whereas the missing values in between and on the right positions should be interpolated. Example:
[1, 3, 5, 7, 9]
interpolated to the new length of 10 would be:
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
This is just the double size and can be solved with the following mathematical formula for interpolation, whereas every second value is interpolated:
y = y1 + ((y2 - y1) / (x2 - x1)) * (x - x1)
But I am trying to figure out, how to interpolate if the list with a length of 217 needs to be interpolated to a length of 240 for example.
Is there a library, which offers a function for this I don't know about? Or maybe someone can give me an example?
Edit: The data in the list is not linear. So a list like this is probable:
[4.534, 1.2433. 3.353, 2.3452, 6.124, 8.124, 1.232]