报错:Python3-ValueError:not enough values to unpack (expected 2, got 0)
具体的错误如下:
Traceback (most recent call last):
File "/Users/zhangsf/code/python/my-project/Subsidy.py", line 83, in <module>
xy1.boxplot(column='ranking', by='subsidy')
File "/Users/zhangsf/anaconda3/lib/python3.7/site-packages/pandas/plotting/_core.py", line 2254, in boxplot_frame
return_type=return_type, **kwds)
File "/Users/zhangsf/anaconda3/lib/python3.7/site-packages/pandas/plotting/_core.py", line 2223, in boxplot
return_type=return_type)
File "/Users/zhangsf/anaconda3/lib/python3.7/site-packages/pandas/plotting/_core.py", line 2682, in _grouped_plot_by_column
keys, values = zip(*gp_col)
ValueError: not enough values to unpack (expected 2, got 0)
It means that python expected there to be two return values from zip(), but there were none.
出错原因:这意味着python期望zip()有两个返回值,但没有一个
出错的语句为:
xy1.boxplot(column='ranking', by='subsidy')
最终发现原因是:导入的数据有问题导致ranking这一列数据为NAN,没有返回值
重新将正确数据引入就ok