首先,对这两个问题似乎有多明显是道歉的;我对此非常非常新,并且不知道我在做什么。Python'AttributeError:'function'object has no attribute'min''
我试图写一些东西来将样条插值的Scipy函数应用到值数组中。我的代码目前看起来是这样的:
import numpy as np
import scipy as sp
from scipy.interpolate import interp1d
x=var
x1 = ([0.1,0.3,0.4])
y1 = [0.2,0.5,0.6]
new_length = 25
new_x = np.linspace(x.min(), x.max(), new_length)
new_y = sp.interpolate.interp1d(x, y, kind='cubic')(new_x)
,但是当它到达行
new_x = np.linspace(x.min(), x.max(), new_length)
我收到以下错误:
AttributeError: 'function' object has no attribute 'min'
,到目前为止,谷歌搜索等已经变成了什么我明白。这是什么意思,我该如何解决?
第二个问题:如何一次输入多行代码?目前,如果我尝试复制整个东西,然后将其粘贴到PyLab中,它只输入我的代码的第一行,所以我必须一次将整个东西粘贴到一行中。我该如何解决这个问题?
请尽量保持问题,只有一个问题,你的第一个(编程)问题是,在这个网站可以接受的,但是,你的第二个(非编程)问题与StackOverflow无关,应该以超级用户的身份询问。 – 2013-04-10 15:46:24
如果你从'scipy.interpolate import interp1d'执行'''',你可以简单地调用'interp1d(...)'。如果你只有'scipy as sp',你必须把它叫做'sp.interpolate.interp1d(...)'你不需要这样做,除非你想单独调用'interp1d(...)'以及'scipy'像'sp.interp()'中的另一个函数,而不显式地从scipy import interp'导入和'from scipy.interpolate import interp1d' – askewchan 2013-04-10 17:23:55