问题
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);
The error is:
---------------------------------------------------------------------------
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'
回答1:
You should pass data parameter instead of edata
sns.countplot(x='Rating', data=Edata);
来源:https://stackoverflow.com/questions/61713669/valueerror-could-not-interpret-input-rating