Example of simple EXCEL data statistics using python, and python data statistics

Source: Internet
Author: User

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.

Related Article

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.