系列文章目录
文章目录
- 系列文章目录
- 前言
- 一、计算指定excel文件指定行指定间隔为一组的CPK
- 1.引入库
- 总结
前言
一、计算指定excel文件指定行指定间隔为一组的CPK
1.引入库
代码如下(示例):
import numpy as np
import matplotlib.pyplot as plt
from openpyxl import load_workbook
import pandas as pddef CPK(data,USL,LSL):mean = np.mean(data)std = np.std(data)cp = (USL - LSL)/(6*std)Cpu = (USL - mean)/(3*std)Cpl = (mean - LSL)/(3*std)Cpk = min(Cpu,Cpl)return Cpkfile_path = "Summaryout-5S1S2.xlsx"
df = pd.read_excel(file_path)
data = df.iloc[1,1:None]
column_count = df.shape[1]
interval = 60
x_axis = 1
Cpk_total = []
interval_total = []
print(column_count)
for i in range(1,column_count,interval):data_cpk = df.iloc[1,i:i+(interval-1)]Cpk_value = CPK(data_cpk,1.5,0)Cpk_total.append(Cpk_value)x_axis = x_axis + 1#print(x_axis)interval_total.append(x_axis)#print(Cpk_value)x = interval_total
y = Cpk_total
x_num = len(x)
plt.plot(x,y)
plt.xticks(ticks=[j for j in range(x_num) if j % 1 == 0], labels = [j for j in range(x_num) if j % 1 == 0])
plt.title('CPK')
plt.xlabel('date')
plt.ylabel('Cpk_value')
plt.grid() #添加网格线
plt.show()
总结
分享:
我试想自己将来会成为一个什么样的人,然后站在未来自己的立场上判断如何做决定,怎样行动,动态的调整自己的生活;