你好朋友我有数据框选项卡,其数据类型如下:
[('Age_class', 'string'),
('Limit', 'bigint'),
('Limit_avg', 'double'),
('Limit_min', 'int'),
('Limit_max', 'int'),
('Percent', 'double')]
我已将“百分比”列转换为使用 参考: Extract column values of Dataframe as List in Apache Spark
fg=tab.select("Percent").collect()
print(fg)
[行(Percent = 16.25),行(Percent = 2.75),行(Percent = 17.0), 行(百分比= 17.75),行(百分比= 11.25),行(百分比= 35.0)] 现在,我正在使用python脚本绘制饼图
labels = list(fg)
sizes = [15, 30, 45, 10]
explode = (0, 0.1, 0, 0)
ax1.pie(sizes, explode=explode,labels=labels, autopct='%1.1f%%',
shadow=True, startangle=90)
ax1.axis('equal')
plt.show()
输出:
ValueError: 'label' must be of length 'x'