【发布时间】:2016-09-21 20:46:52
【问题描述】:
我正在尝试使用 scipy 包进行 2d 推断,例如:
interp2d(df['maturity'], df['strike'], df['IV'], fill_value='extrapolate')(0.08, 0.65)
df['maturity'] 的最小值是 0.09,我得到以下错误:
IV = interp2d(group['maturity'], group['strike'], group['IV'], fill_value='extrapolate')(0.08, 0.65)
File "C:\Anaconda2\lib\site-packages\scipy\interpolate\interpolate.py", line 298, in __call__
z[:, out_of_bounds_x] = self.fill_value
ValueError: could not convert string to float: extrapolate
fill_value='extrapolate' 在 interp1d 上完美运行...知道是否有一种简单的方法可以在 2d 方法上进行推断?
谢谢。
【问题讨论】:
-
它在抱怨字符串值,那么这里的 dtype 是什么?
df.info()显示什么? -
code <class 'pandas.core.frame.DataFrame'> date 72 non-null datetime64[ns] IV 72 non-null float64 maturity 72 non-null float64 strike 72 non-null float64问题似乎来自它使用 z[:, out_of_bounds_x] = self.fill_value 并尝试以某种方式传递字符串的事实。事实上,我认为它尝试像这样传递两个值 :(0.08, 0.65) 并看到它有一个字符串
标签: python python-2.7 pandas scipy