我正在尝试创建一个函数,该函数将遍历数据框中的数字特征列表,以在其旁边显示直方图和汇总统计信息。我正在使用plt.figtext()
显示统计信息,但出现错误
num_features=[n1,n2,n3]
for i in num_features:
fig, ax = plt.subplots()
plt.hist(df[i])
plt.figtext(1,0.5,df[i].describe() )
ax.set_title(i)
plt.show()
当我这样做时,我收到一条错误/警告消息:
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()
如果使用df[n].mean()
而不是它工作正常describe()
我究竟做错了什么?有没有更好的方法来打印一个图并在它旁边显示一些统计数据?
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句