帕累托图 (Pareto chart) 是将出现的质量问题和质量改进项目按照重要程度依次排列 而采用的一种图表。以[意大利]经济学家V.Pareto的名字而命名的。

帕累托图又叫排列图、主次图,是按照发生频率大小顺序绘制的直方图,表示有多少结果是由已确认类型或范畴的原因 所造成。

ABC分类法(Activity Based Classification) ,全称ABC分类库存控制法。又称帕累托分析法或巴雷托分析法、柏拉图分析、主次因分析法 、ABC分析法、分类管理法、物资重点管理法、ABC管理法、abc管理、巴雷特分析法,也称之为“80对20”规则,EMBA、MBA等主流商管教育均对ABC分类法对企业管理的启示及对管理者组织决策的影响有所介绍。

  • A类因素,发生累计频率为0%~80%,是主要影响因素。
  • B类因素,发生累计频率为80%~90%,是次要影响因素。
  • C类因素,发生累计频率为90%~100%,是一般影响因素。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
# 解决plt中文显示问题
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False
pd.set_option('display.unicode.ambiguous_as_wide',True)
pd.set_option('display.unicode.east_asian_width',True)


data = pd.DataFrame({
"name":['百香果','猕猴桃','草莓','桃子','苹果', '梨', '葡萄', '车厘子', '榴莲','蓝莓','橙子','橘子'],
"f": [1,5,6,3,11, 13, 25, 47, 27,37,68,89],
})
d = data.groupby(by=['name'],as_index=False)['f'].sum()
d['name2'] = d['name'].map(lambda x: '\n'.join(x))

d1 = pd.Series(np.array(d['f']),index = np.array(d['name2']))
d1.sort_values(ascending=False, inplace= True)

c = pd.Series(np.array(d['f']),index = np.array(d['name']))
c.sort_values(ascending=False, inplace= True)

ax1 = plt.subplot(1, 1, 1)
ax1.bar(d1.index, d1, color='#527C5A',width=0.9), #判断大于0的为红色,负的为蓝色
ax1.spines['bottom'].set_linewidth(1);###设置底部坐标轴的粗细

cindex = np.arange(len(d1))
for a,b,y in zip(cindex,d1,c): #柱子上的数字显示
plt.tick_params(labelsize=12)
plt.text(a,b,'%.0f'%(y),ha='center',va='bottom',fontsize=12);


biaoti ='统计'
plt.title(biaoti,fontsize=15)

p = d1.cumsum()/d1.sum() # 创建累计占比,Series
key = p[p>0.8].index[0]
key_num = d1.index.tolist().index(key)


cp = c.cumsum()/c.sum() # 创建累计占比,Series
ckey = cp[cp>0.8].index[0]
ckey_num = c.index.tolist().index(ckey)


print('超过80%累计占比的节点值索引为:' ,ckey)
print('超过80%累计占比的节点值索引位置为:' ,ckey_num)
print('------')
# 找到累计占比超过80%时候的index
# 找到key所对应的索引位置

ckey_product = c.loc[:ckey]
print('核心产品为:')
print(ckey_product)
# 输出决定性因素产品

p.plot(style = '--ko', secondary_y=True) # secondary_y → y副坐标轴
ax1.axvline(key_num,color='r',linestyle="--",alpha=0.8)
plt.text(key_num+0.2,p[key],'累计占比为:%.2f%%' % (p[key]*100), color = 'r') # 累计占比超过80%的节点
plt.ylabel('累\n计\n比\n例',rotation=0)
1
2
3
4
5
6
7
8
9
10
超过80%累计占比的节点值索引为: 榴莲
超过80%累计占比的节点值索引位置为: 4
------
核心产品为:
橘子 89
橙子 68
车厘子 47
蓝莓 37
榴莲 27
dtype: int64