Understanding the interpolation technique

Interpolation is a technique used quite frequently in finance. In the following example, we have to replace two missing values, NaN, between 2 and 6. The pandas.interpolate() function, for a linear interpolation, is used to fill in the two missing values:

import pandas as pd 
import numpy as np 

The output is shown here:

0    1.000000
1    2.000000
2    3.333333
3    4.666667
4    6.000000
dtype: float64

The preceding method is a linear interpolation. Actually, we could estimate a Δ and calculate those missing values manually:

Understanding the interpolation technique

Here, v2(v1) is the second (first) value ...

Get Python for Finance - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.