数据挖掘与数据分析

贡献度分析(帕累托分析)

2018-07-17  本文已影响0人  LingHun

对是个菜品A1-A10某个月的盈利额分析


分析资料
#-*- coding: utf-8 -*-
#菜品盈利数据 帕累托图
from __future__ import print_function
import pandas as pd

#初始化参数
dish_profit = 'G:/PycharmProjects/数据分析与挖掘/catering_dish_profit.xls' #餐饮菜品盈利数据
data = pd.read_excel(dish_profit, index_col = u'菜品名')
data = data[u'盈利'].copy()
data.sort_values(ascending = False)
 
import matplotlib.pyplot as plt #导入图像库
plt.rcParams['font.sans-serif'] = ['SimHei'] #用来正常显示中文标签
plt.rcParams['axes.unicode_minus'] = False #用来正常显示负号

plt.figure()
data.plot(kind='bar')
plt.ylabel(u'盈利(元)')
p = 1.0*data.cumsum()/data.sum()
p.plot(color = 'r', secondary_y = True, style = '-o',linewidth = 1)

# xy设置箭头尖的坐标
# xytext设置注释内容显示的起始位置
# arrowprops 用来设置箭头

plt.annotate(format(p[6], '20%'), xy = (6, p[6]), xytext=(6*0.9, p[6]*0.9), 
             arrowprops=dict(arrowstyle="->", connectionstyle="arc3,rad=.2")) 
             #添加注释,即85%处的标记。这里包括了指定箭头样式。
             #format(p[6], '20%')  20%为箭头尾部的线的长度
             #connectionstyle="arc3,rad=.2" 指的是指向箭头的弯曲程度
plt.ylabel(u'盈利(比例)')
plt.show()

分析结果
上一篇 下一篇

猜你喜欢

热点阅读