Это мои данные:
date_num,expiry_num,strike,value,interp
731988,731988,0.02501,0.0095094,0.0095094
731988,731988,0.03001,0.0091658,0.0096807
731988,731988,0.03501,0.0089164,0.009852
731988,731988,0.03751,0.0088471,0.00993765
731988,731988,0.04001,0.0088244,0.0100233
731988,731988,0.04251,0.008853,0.01010895
731988,731988,0.04501,0.00898,0.0101946
731988,731988,0.04751,0.009066,0.01028025
731988,731988,0.05001,0.0092429,0.0103659
731988,731988,0.05251,0.009458,0.01045155
731988,731988,0.05501,0.0097043,0.0105372
731988,731988,0.06001,0.010264,0.0107085
731988,731988,0.06501,0.0108798,0.0108798
731988,732018,0.02501,0.0095094,0.0095094
731988,732018,0.03001,0.0091658,0.0096807
731988,732018,0.03501,0.0089164,0.009852
731988,732018,0.03751,0.0088471,0.00993765
731988,732018,0.04001,0.0088244,0.0100233
731988,732018,0.04251,0.008853,0.01010895
731988,732018,0.04501,0.00898,0.0101946
731988,732018,0.04751,0.009066,0.01028025
731988,732018,0.05001,0.0092429,0.0103659
731988,732018,0.05251,0.009458,0.01045155
731988,732018,0.05501,0.0097043,0.0105372
731988,732018,0.06001,0.010264,0.0107085
731988,732018,0.06501,0.0108798,0.0108798
731988,732079,0.02543,0.0094153,0.0094153
731988,732079,0.03043,0.0090666,0.009585463
731988,732079,0.03543,0.0088118,0.009755625
731988,732079,0.03793,0.0087399,0.009840706
731988,732079,0.04043,0.0087152,0.009925788
731988,732079,0.04293,0.0087425,0.010010869
731988,732079,0.04543,0.0088643,0.01009595
731988,732079,0.04793,0.0089551,0.010181031
731988,732079,0.05043,0.0091326,0.010266113
731988,732079,0.05293,0.0093489,0.010351194
731988,732079,0.05543,0.0095964,0.010436275
731988,732079,0.06043,0.0101587,0.010606438
731988,732079,0.06543,0.0107766,0.0107766
731988,732170,0.02597,0.0095394,0.0095394
731988,732170,0.03097,0.0091987,0.009711525
731988,732170,0.03597,0.0089515,0.00988365
731988,732170,0.03847,0.008883,0.009969713
731988,732170,0.04097,0.008861,0.010055775
731988,732170,0.04347,0.0088902,0.010141838
731988,732170,0.04597,0.0090131,0.0102279
731988,732170,0.04847,0.0091035,0.010313963
731988,732170,0.05097,0.0092803,0.010400025
731988,732170,0.05347,0.0094953,0.010486088
731988,732170,0.05597,0.0097414,0.01057215
731988,732170,0.06097,0.0103008,0.010744275
731988,732170,0.06597,0.0109164,0.0109164
731988,732353,0.04685,0.0091422,0.0091422
А вот мой скрипт:
import pandas as pd
from scipy.interpolate import griddata
df = pd.read_csv("base_data.csv")
df["interp"] = griddata(
df[["expiry_num","strike"]].values,
df["value"].values,df[["expiry_num","strike"]].values,
method='linear')
import matplotlib.pyplot as plt
plt.scatter(df.loc[df["expiry_num"] == 732018,"strike"],df.loc[df["expiry_num"] == 732018,"value"])
plt.scatter(df.loc[df["expiry_num"] == 732018,"strike"],df.loc[df["expiry_num"] == 732018,"interp"])
plt.show()
Результат выглядит так:
введите описание изображения здесь
Почему данные сетки не выполняют интерполяцию?