我不断得到“TypeError:len()of unsized object” 当试图创建一个使用索引作为x值和价格作为y值的绘图时。你知道吗
def tsplot2(y, title, lags=None, figsize=(12,8)):
if not isinstance(y, pd.Series):
y = pd.Series(y)
fig= plt.figure(figsize=figsize)
layout=(2,2)
ts_ax=plt.subplot2grid(layout, (0,0))
hist_ax=plt.subplot2grid(layout, (0,1))
acf_ax=plt.subplot2grid(layout, (1,0))
pacf_ax=plt.subplot2grid(layout, (1,1))
y.plot(ax=ts_ax)
ts_ax.set_title(title, fontsize=14, fontweight='bold')
y.plot(ax=hist_ax, kind='hist', bins=25)
hist_ax.set_title('Histogram')
smt.graphics.plot_acf(y, lags=lags, ax=acf_ax)
smt.graphics.plot_pacf(y, lags=lags, ax=pacf_ax)
sns.despine()
plt.tight_layout()
return ts_ax, acf_ax, pacf_ax
num_var= len(series.iloc[1,:])
for i in range(0, num_var):
tsplot2(series.iloc[:,i].dropna() , title=series.columns[i], lags=48)
我修正了密码。我想到了 “如果不存在(y,pd系列): y=pd系列(y) ““ 当我可以将series插入函数时,也不需要使用for循环。你知道吗
相关问题 更多 >
编程相关推荐