ValueError:无法解释输入“评级" [英] ValueError: Could not interpret input 'Rating'
本文介绍了ValueError:无法解释输入“评级"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在我的文件中添加一个图形,它显示以下错误并打印一个空图形.我想在具有值(1,2,3,4,5)的等级列与每个等级中的行数之间绘制图表. 这是代码:
I want to add a graph to my file and it shows the following error and prints an empty graph. I want to plot a graph between the rating column that has values (1,2,3,4,5) and the number of rows in each rating. This is the code:
sns.set(rc={'figure.figsize':(6,6)})
plt.title('Distribution of Ratings')
sns.countplot(x = 'Rating', Edata = Edata);
错误是:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-77-32533aad2dd0> in <module>
1 sns.set(rc={'figure.figsize':(6,6)})
2 plt.title('Distribution of Ratings')
----> 3 sns.countplot(x = 'Rating', Edata = Edata);
~/opt/anaconda3/lib/python3.7/site-packages/seaborn/categorical.py in countplot(x, y, hue,
data, order, hue_order, orient, color, palette, saturation, dodge, ax, **kwargs)
3553 estimator, ci, n_boot, units, seed,
3554 orient, color, palette, saturation,
-> 3555 errcolor, errwidth, capsize, dodge)
3556
3557 plotter.value_label = "count"
~/opt/anaconda3/lib/python3.7/site-packages/seaborn/categorical.py in __init__(self, x, y,
hue, data, order, hue_order, estimator, ci, n_boot, units, seed, orient, color, palette,
saturation, errcolor, errwidth, capsize, dodge)
1613 """Initialize the plotter."""
1614 self.establish_variables(x, y, hue, data, orient,
-> 1615 order, hue_order, units)
1616 self.establish_colors(color, palette, saturation)
1617 self.estimate_statistic(estimator, ci, n_boot, seed)
~/opt/anaconda3/lib/python3.7/site-packages/seaborn/categorical.py in
establish_variables(self, x, y, hue, data, orient, order, hue_order, units)
150 if isinstance(var, str):
151 err = "Could not interpret input '{}'".format(var)
--> 152 raise ValueError(err)
153
154 # Figure out the plotting orientation
ValueError: Could not interpret input 'Rating'
推荐答案
您应该传递data参数而不是edata
You should pass data parameter instead of edata
sns.countplot(x='Rating', data=Edata);
这篇关于ValueError:无法解释输入“评级"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文