Skip to content Skip to sidebar Skip to footer

Python - Interpolation On Dataframe Values

My code: import pandas as pd import numpy as np from scipy.interpolate import interp1d def interpolate_iv_my(x,y,newX_Value): y_interp = interp1d(x,y) iv = y_interp(newX_

Solution 1:

I think your interpolate_iv_my function isn't working properly.

But the correct code for applying function to all rows in a dataframe and creating new column based on those results is this:

df['interpolate'] = df.apply(lambda row: interpolate_iv_my(row, x, 52), axis=1)

Post a Comment for "Python - Interpolation On Dataframe Values"