我知道这个问题已经存在了,但答案对我没有帮助。
def function(T,theta,A):
x=(T-theta)/A
return(x)
filen=pd.read_csv('filename')
filelist=[file,file2,...,filen)
labels=['name1','name2',...]
colors=['red','blue','green',...]
for i in range(len(filelist)):
x=filelist[i]['column1']
y=filelist[i]['column2']
y2=(1/y)
plt.plot(x, y2, colors[i], label=labels[i])
plt.legend()
plt.plot()
w=np.where(x>170)
print(x[w]) #error, can only tuple index with multiindex
other_fit=curve_fit(function,x,y)
popt, pcov=other_fit
plt.plot(x, function(x, *popt), colors2[i], label=labels2[i])
plt.show()
错误发生在x[w]
。
当我不在for循环中时,没有错误。
The error message is as follows:
ValueError: Can only tuple-index with a MultiIndex
尝试更改:
致:
np.where
在您的情况下返回一个元组:相关问题 更多 >
编程相关推荐