Python uses pandas to complete operations on Excel: Traversing, skewness (skew) applet

Source: Internet
Author: User

Excel has a computational function skew () for skewness, but it is unclear how to traverse with Excel, which has a large amount of data.

Try using Python for resolution.

The first time to learn python, did not expect to overcome the installation of various packages of sadness, incredibly successful implementation.

python3.3:

#this is a test case#-*-coding:gbk-*-print ("Hello python! Chinese") #env configimport xlrdimport osimport xlwt3import Numpyim Port pandas as Pd#from pandas import series,dataframe#import pandasdata = 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 Numline_num=table.nrowscell_sectiona=table.cell (1,0). Valuecell_sectionb=table.cell ().  Value#print (Cell_sectiona) #print (CELL_SECTIONB) Start_value=cell_sectiona#we need to recode the start value; 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 ()) #afte        R 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 ')

  

Python uses pandas to complete operations on Excel: Traversing, skewness (skew) applet

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.