Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pandas interpolate: slinear vs index

In Pandas interpolate what is the difference between using method of slinear vs index?

like image 695
Alex Rothberg Avatar asked Oct 16 '25 15:10

Alex Rothberg


1 Answers

method='slinear' will only interpolate "inside" values. It will not interpolate None values that do not have a valid value on both sides.

Using index values will default to limit_direction='forward' which will interpolate inside values and anything after a non NaN value.

Notice in the other posted example, if you set v to None where either t is 100 or where t is 11 (both ends of the sorted index), the result will not be interpolated when using method='slinear'. This is VERY useful for interpolating values inside a series, when you don't want to extending the series.

Thanks to @TomAugspurger on GitHub for explaining this.

like image 158
Gronk Avatar answered Oct 18 '25 20:10

Gronk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!