我有一个 27 列的 excel 文件。我想编写一个 python 代码,它逐列读取并将最后 5 个值存储在 coloum 中,这将对它们进行数学方程。
到目前为止我有这个:
from math import tan
#Write Header
#outFile.write('Test Name,X+ avg,X+ std,X+ count,X- avg,X- std,X- count,X angle,Y+ avg,Y+ std,Y+ count,Y- avg,Y- std,Y- count,Y angle\n')
#for line in inFile:
if 1==1:
line = [1,2,38.702,37.867,35.821, 44, 49,55,65,20,25,28,89.]
line0= len(line)
print "the list size"
print line0
line1 = len(line) -5 #takes the overall line and subtracts 5.
print "the is the start of the 5 #'s we need"
print line1 #prints the line
d= line[line1:line0] #pops all the values from in the line (..)
print "these are the 5 #'s we need"
print d
lo=min(d)
hi=max(d)
print "the lowest value is"
print lo
print "the highest value is"
print hi
average1 = float (sum(d))/ len(d) #sum
print "the average of the values is"
print average1
“line = [1,2,38.702,37.867,35.821, 44, 49,55,65,20,25,28,89.]”部分我希望 python 自动读取列,存储最后 5 个值和做上面的数学分析。