我正在尝试使用Matplotlib绘制饼图,尽管没有负值,但我不断收到错误消息:“ pie不允许负值”!
contrib = sales_data.groupby('Region')['Sales2016'].sum().round().reset_index()
contrib["Percentage"] = (contrib.Sales2016/sum(contrib.Sales2016))*100
contrib = contrib.drop(columns = ["Sales2016"])
contrib.plot(kind = "pie", subplots = True).plot(kind = "pie",subplots=True,legend=False,figsize=(12,5),autopct="%.2f%%")
plt.show()
是否可以指出我要去哪里错了?以下是contrib的输出:
Region Percentage
0 Central 32.994771
1 East 42.701319
2 West 24.303911