Получение ValueError: Не удалось интерпретировать ввод 'State' - PullRequest
0 голосов
/ 23 октября 2019

Когда я пытаюсь построить диаграмму, получаю ошибку значения

fig, ax1 = plt.subplots()  
fig.set_size_inches(15,  9)  
ax1 = sns.barplot(x="State", y="Population", data_set=data_set.sort_values('UnEmpRate'), palette="Set2") 
ax1.set(xlabel='States', ylabel='Population In Millions')  ax1.set_title('Population in Millions by State', size=20) 
plt.xticks(rotation=-90)
> ValueError                                Traceback (most recent call last) <ipython-input-56-71c26cd50745> in
> <module>
>       3 fig, ax1 = plt.subplots()
>       4 fig.set_size_inches(15,  9)
> ----> 5 ax1 = sns.barplot(x ="State", y ="Population", data_set= data_set.sort_values('UnEmpRate'), palette ="Set2")
>       6 ax1.set(xlabel ='State', ylabel ='Population In Millions')
>       7 ax1.set_title('Population in Millions by State', size = 20)
> 
> C:\Anacondainterpreter\lib\site-packages\seaborn\categorical.py in
> barplot(x, y, hue, data, order, hue_order, estimator, ci, n_boot,
> units, orient, color, palette, saturation, errcolor, errwidth,
> capsize, dodge, ax, **kwargs)    3147                          
> estimator, ci, n_boot, units,    3148                          
> orient, color, palette, saturation,
> -> 3149                           errcolor, errwidth, capsize, dodge)    3150     3151     if ax is None:
> 
>  1. C:\Anacondainterpreter\lib\site-packages\seaborn\categorical.py in __init__(self, x, y, hue, data, order, hue_order, estimator, ci, n_boot, units, orient, color, palette, saturation, errcolor, errwidth,
> capsize, dodge)
>            1605         """Initialize the plotter."""
>            1606         self.establish_variables(x, y, hue, data, orient,
>         -> 1607                                  order, hue_order, units)
>            1608         self.establish_colors(color, palette, saturation)
>            1609         self.estimate_statistic(estimator, ci, n_boot)
>         
>         C:\Anacondainterpreter\lib\site-packages\seaborn\categorical.py in
> establish_variables(self, x, y, hue, data, orient, order,
>     hue_order, units)
>             153                 if isinstance(input, string_types):
>             154                     err = "Could not interpret input '{}'".format(input)
>         --> 155                     raise ValueError(err)
>             156 
>             157             # Figure out the plotting orientation
> 
> ValueError: Could not interpret input 'State'
...