Let’s begin by first importing the function that will be used to perform the interpolation.Īs already introduced, the function is called interpolate.interp1d( ) and belongs to the Scipy package. interp() to perform in an easy and immediate way this task. To do that, we will rely on the Python library Scipy, more specifically on one of its packages called interpolate which provide the function.
#SCIPY INTERPOLATE HOW TO#
The following paragraphs explain how to perform an interpolation when dealing with 1, 2 or 3-dimensional data sets. With this being said, I hope I convinced you that interpolation represents a powerful tool for data analysis, for making predictions and for a lot of other different applications. Of course, all this procedure is performed automatically by our terminal we only receive as output the values of the points that we are interested in.
This can be done by first calculating the function that best describes the trend of our known data points and then by evaluating the value of that function in specific unknown points. From a mathematical point of view, interpolation indicates the process of obtaining the value of specific unknown data points that are located between some other known data points, after having described the known set of data points with an opportune function.įor example, if we have a series of data points x 0, x 1, x 2,…x n and we know the values y 0, y 1, y 2,…y n (with y n = f(x n)), through the process of interpolation, we can determine the value y m = f(x m), where x m is a point located in between two of the already known points, i.e.