【发布时间】:2018-09-20 12:47:55
【问题描述】:
你好 StackOverflow 的好人!
我已经开始掌握 Python,并且开始对自己知道自己在做什么感到非常自信,直到出现了这个笨蛋:
我正在绘制和比较“类型”=“区域”和“”的数据框的两个子选择。 Seaborn 绘制了这些的箱线图并标记了平均值,但是当我使用 .mean() 计算平均值时,它给出了不同的答案。代码如下:
plotdata = df[df['Type'].isin(['A','B'])]
g = sns.violinplot(x="Type", y="value", data=plotdata, inner="quartile")
plt.ylim(ymin=-4, ymax=4) # This is to zoom on the plot to make the 0 line clearer
This is the resulting plot, note how the means are ~-0.1 and ~1.5
但是当我计算它们时:
print(df_long[df_long['charttype'].isin(['area'])]['error'].mean())
print(df_long[df_long['charttype'].isin(['angle'])]['error'].mean())
返回:
0.014542483333332705
-2.024809368191722
所以我的问题是,为什么这些数字不匹配?
【问题讨论】:
-
谢谢斯科特,第一次来这里,我找到了答案,但如果我再次询问,我一定会发布数据。谢谢!!