use python with pandas to get the skew in excel
write @2014 author: hixichen
use python to read the data in excel and generate the skew().
python3.3:
#this is a test case
-- coding: gbk --
print(“hello python!中文”)
#env config import xlrd import os import xlwt3 import numpy
import pandas as pd #from pandas import Series,DataFrame #import pandas
data = xlrd.open_workbook(“E:\data.xlsx”) table = data.sheets()[0] #this need to be verify more
#print (“check”) print (table.nrows) print (table.name) print ("############################")
#total line num line_num=table.nrows
cell_sectionA=table.cell(1,0).value cell_sectionB=table.cell(1,1).value #print (cell_sectionA) #print (cell_sectionB)
start_value=cell_sectionA
#we need to recode the start value ,but not the end. sectionB_each_time_start=0 #sectionB_each_time_end=i is ok.
for i in range(1,line_num): if start_value != table.cell(i,0).value: cacu_num=i-sectionB_each_time_start; #print (cacu_num) #print ("********************************") data={} for j in range(0,(cacu_num-1)): data[j]= table.cell((sectionB_each_time_start+j+1),1).value #print (data[j])
df = pd.Series(data)
#print("skew\t")
#print("skew: %d %f" %(table.cell(sectionB_each_time_start+1,0).value,df.skew()))
print("%d"%table.cell(sectionB_each_time_start+1,0).value)
#print("%f" %df.skew())
#after caculate ,update the variable.
sectionB_each_time_start=i-1
start_value=table.cell(i,0).value
#file=xlwt3.Workbook() #table_for_wt=file.add_sheet(“test1”);
#table_for_wt.write(0,0,cell_b) #table_for_wt.write(1,1,cell_b) #file.save(‘E:\wtest.xls’)