我想在文件中添加一个图,它显示以下错误并打印一个空图。我想在具有值(1,2,3,4,5(的评级列和每个评级中的行数之间绘制一张图。这是代码:
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'
您应该传递数据参数,而不是edata
sns.countplot(x='Rating', data=Edata);