Example of simple EXCEL data statistics using python, and python data statistics
Task:
Use the simple python time statistical task-count the number of male and female persons respectively.
Materials used: xlrd its function-reading excel table data
Code:
Import xlrdworkbook = xlrd.open_workbook('demo.xlsx') # Open the excel Data Table SheetList = workbook. sheet_names () # Read the workbook to the list. SheetName = SheetList [0] # Read the name of the first workbook. Sheet1 = workbook. sheet_by_index (0) # The e-Table index starts from 0. Sheet1 = workbook. sheet_by_name (SheetName) # instantiate the workbook object m = 0f = 0for I in range (Sheet1.nrows): rows = Sheet1.row _ values (I) if rows [2] = 'male ': m + = 1 elif rows [2] = 'female': f + = 1 print ('male: ', m, 'female:', f)
The above example of using python to implement simple EXCEL Data Statistics is all the content shared by the editor. I hope to give you a reference and support for the help house.