我有这个数据框:
df = {'DATE': [43390, 43599, 43605, 43329, 43440],
'STORE': [1, 1, 1, 2, 2],
'LYLTY_CARD_NBR': [1000, 1307, 1343, 2373, 2426],
'TXN_ID': [1, 348, 383, 974, 1038],
'PROD_QTY': [2, 3, 2, 5, 3],
'TOT_SALES': [6.0, 6.3, 2.9, 15.0, 13.8]}
transac = pd.DataFrame(df)
DATE STORE LYLTY_CARD_NBR TXN_ID PROD_QTY TOT_SALES
0 43390 1 1000 1 2 6.0
1 43599 1 1307 348 3 6.3
2 43605 1 1343 383 2 2.9
3 43329 2 2373 974 5 15.0
4 43440 2 2426 1038 3 13.8
当我试图从TOT_SALES专栏的seaborn中绘制箱线图时,我得到了这个错误。列的类型为float64。我在matplotlib上也尝试了同样的方法,但在seaborn上没有:
sns.boxplot(y='TOT_SALES', df=transac)
ValueError Traceback (most recent call last)
<ipython-input-16-29f35d075db2> in <module>
----> 1 sns.boxplot(y='TOT_SALES', df=transac)
~\Anaconda3\lib\site-packages\seaborn\categorical.py in boxplot(x, y, hue, data, order, hue_order, orient, color, palette, saturation, width, dodge, fliersize, linewidth, whis, ax, **kwargs)
2239 plotter = _BoxPlotter(x, y, hue, data, order, hue_order,
2240 orient, color, palette, saturation,
-> 2241 width, dodge, fliersize, linewidth)
2242
2243 if ax is None:
~\Anaconda3\lib\site-packages\seaborn\categorical.py in __init__(self, x, y, hue, data, order, hue_order, orient, color, palette, saturation, width, dodge, fliersize, linewidth)
441 width, dodge, fliersize, linewidth):
442
--> 443 self.establish_variables(x, y, hue, data, orient, order, hue_order)
444 self.establish_colors(color, palette, saturation)
445
~\Anaconda3\lib\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 'TOT_SALES'
问题在哪里
错误的来源是您通过了transacasdf 参数,seaborn不使用该参数。将其作为数据传递:
相关问题 更多 >
编程相关推荐