You can create a function using scipy.interp1d :
import numpy as np from scipy import interpolate data = np.genfromtxt('data.txt') x = data[:,0]
If you want to smooth your data, you can use univariatespline , just replace the line f = interpolate... with:
f = interpolate.UnivariateSpline(x, y)
To change how smooth it is, you can play with the s and k parameters:
f = interpolate.UnivariateSpline(x, y, k=3, s=1)
As described in the documentation
source share