【发布时间】:2020-08-17 07:37:08
【问题描述】:
我有数据框。
df=df.astype(np.float)
df.head()
x y
1 0.6 2
0 1.1 1
3 3.4 4
2 4.3 3
我正在尝试使用它生成箱线图。
ax= plt.gca()
ax.boxplot(df[['x','y']])
但出现以下错误:
TypeError: cannot perform reduce with flexible type
我无法理解为什么,因为数据框中的所有值都是数字。
【问题讨论】:
-
df有 2 列还是 3 列? [1,0,3,2] 只是索引? -
只有两列
-
我的错误是:
NameError: name 'ax' is not defined -
@ipj 因为必须使用
ax = plt.gca()。 -
打错字了,抱歉。
标签: python pandas matplotlib