从数据帧在Python中创建饼图
我只是想创建 2 个饼图,一个基于 SalesQuantity,一个基于 ProfitPerBottle。我的代码和表格如下所示
HenSalePur["ProfitPerBottle"] = HenSalePur['SalesPrice'] - HenSalePur['PurchasePrice']
DonJSalePur["ProfitPerBottle"] = DonJSalePur['SalesPrice'] - DonJSalePur['PurchasePrice']
HenSalePur["TotalProfit"] = HenSalePur['ProfitPerBottle'] * HenSalePur['SalesQuantity']
DonJSalePur["TotalProfit"] = DonJSalePur['ProfitPerBottle'] * DonJSalePur['SalesQuantity']
DonJVolumeGrouped = DonJSalePur.groupby('Size').agg('sum')
print(DonJVolumeGrouped)
I am just trying to create 2 pie charts, one based on SalesQuantity and one based on ProfitPerBottle. My code and tables are shown below
HenSalePur["ProfitPerBottle"] = HenSalePur['SalesPrice'] - HenSalePur['PurchasePrice']
DonJSalePur["ProfitPerBottle"] = DonJSalePur['SalesPrice'] - DonJSalePur['PurchasePrice']
HenSalePur["TotalProfit"] = HenSalePur['ProfitPerBottle'] * HenSalePur['SalesQuantity']
DonJSalePur["TotalProfit"] = DonJSalePur['ProfitPerBottle'] * DonJSalePur['SalesQuantity']
DonJVolumeGrouped = DonJSalePur.groupby('Size').agg('sum')
print(DonJVolumeGrouped)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设您已将表格数据加载到 pandas DataFrame 中,您可以使用下面的代码来检索所需的绘图:
Assuming you have your tabular data loaded into a pandas DataFrame, you can use the code below to retrieve the required plots: