How to interpolate values with Pandas

1 min

The Pandas library will give you the tools to fill the NaN values.

One of its methods, DataFrame.interpolate() can be used to interpolate NaN values.

Interpolation is a way to estimate the values in between two known values.

Linear Interpolation - Source wikipedia
Polynomial Interpolation - Source wikipedia

Here the blue line gives an interpolation in between red dots.

Or so it estimates what can of value it could potentially be.

DataFrame.interpolate() can receive few arguments, but the most important for us today is the method argument.

The method argument will specify what kind of method we want to use, as shown in the two graphs above.

It can accept wide range of methods shown in the following :

interpolation method that can be used by DataFrame.interpolate

Here you are ! You now know how to interpolate values using pandas interpolate method.