前面的data_b可以append,后面的怎么不行呢?iaqisappend最后只是一个一行一列的矩阵
import math
import pandas as pd
import numpy as np
def Compare(a,b,c,d,e,f,value):
if a>value:
bpl=0
bph = a
iqh=50
iql = 0
else:
if b>value:
bpl=a
bph=b
iqh=150
iql = 100
else:
if c>value:
bpl=b
bph=c
iqh=200
iql = 150
else:
if d>value:
bpl = c
bph = d
iqh=300
iql=200
else:
if e>value:
bpl=d
bph =e
iql=300
iqh=400
else:
bpl=e
bph =f
iqh=500
iql=400
return int(bpl),int(bph),int(iqh),int(iql)
def compare2(A):
B=0
if A>B:
B =A
return B
xlsx1 = pd.ExcelFile("C:\Users\86182/Desktop\shuju2.xlsx")
xlsx2 = pd.ExcelFile("C:\Users\86182/Desktop\duizhao.xlsx")
frame = pd.read_excel(xlsx1)
frame2 = pd.read_excel(xlsx2)
data_D = frame2.iloc[0:7,1:9]
A = frame.iloc[497:501,2:9]
for x in range(4):
Data = A.iloc[x]
for y in range(6):
data = Data[y]
Data_b = data_D.iloc[y]
data_b = []
iaqis = []
for z in range(6):
new = Data_b.iloc[z]
data_b.append(new)
# print(data_b)
(bpl,bph,iqh,iql) = Compare(data_b[0],data_b[1],data_b[2],data_b[3],data_b[4],data_b[5],data)
iaqi = ((iqh-iql)*(data-bpl)/(bph-bpl))+iql
iaqi = math.ceil(iaqi)
iaqis.append(iaqi)
print(data,bpl,bph,iqh,iql,iaqi)