Crawler re-exploration (v) ——— crawl app data-Super curriculum "three"--date and time analysis

Source: Internet
Author: User

Then organize the relationship between time and date and posting volume.

    PROJECT2: Date (select 2015 year)

The code is as follows: (The kebiao_all.xlsx here is all the data captured before)

Import Xlrdimport xlsxwriter# The time list to get the data----->dates_listfname = ' kebiao_all.xlsx ' BK = Xlrd.open_workbook (fname) #  Shxrange = range (bk.nsheets) sh = bk.sheet_by_name (' Sheet1 ') nrows = Sh.nrowsncols = sh.ncols# Get 2015 year-round data # actually here date_16_l You can't use it, it's written for logic. date_15_l = []date_16_l = []for i in range (1, nrows): Row_data_date = Sh.row_values (i) [3] #print (row_data_d ATE) Y_a_m = Row_data_date.split ('/') if y_a_m[0] = = ':d ate_15_l.append (y_a_m) Else:date_16_l.append (y_a_m) # Create a spreadsheet workbook = Xlsxwriter. Workbook (' statistic_date.xlsx ') worksheet = Workbook.add_worksheet () worksheet.set_column (' a:a ', ten) worksheet.set_ Column (' B:b ', 5) # takes out the date and groups it, then writes Def every_m (m):d t_15_ml = []for dt_15 in date_15_l:if dt_15[1] = = str (m):d T_15_ml.append ( DT_15) worksheet.write (m,0,dt_15[1]+ ' month ') Worksheet.write (M,1,len (DT_15_ML)) for M in Range (1,13): Every_m (m) Workbook.close ()

In the resulting Excel simple graphing, the output is as follows:

    PROJECT3: Time

Import Xlrdimport xlsxwriter# Get 24 time periods----->time_listtime_list = []for i in Range (0,24): if i < 10:i = ' 0 ' +str (i) Else: i = str (i) time_list.append (i) #print (time_list) #获取数据的时间列表----->times_listfname = ' kebiao_all.xlsx ' BK = Xlrd.open_ Workbook (fname) #shxrange = range (bk.nsheets) sh = bk.sheet_by_name (' Sheet1 ') nrows = Sh.nrowsncols = Sh.ncolstimes_list = []for I in range (1, nrows): Row_data_time = Sh.row_values (i) [4] #print (row_data_time) Times_list.append (row_data_time) # Print (len (times_list)) workbook = Xlsxwriter. Workbook (' statistic_time.xlsx ') worksheet = Workbook.add_worksheet () worksheet.set_column (' a:a ', ten) worksheet.set_ Column (' B:b ', 5) def every_time (i): num = 0for times in Times_list:if str (times) [0]+str (Times) [1] = = I:num + = 1worksheet.wri Te (int (i), 0,str (i) + ' point ') worksheet.write (int (i), 1,num) print (i+ '----> ' +str (num)) for I in Time_list:every_time (i) Workbook.close ()

Look closely to find that this and the previous QQ chat data analysis is very similar.

The output is as follows:

At this point, after a simple data processing and analysis, has been able to do a simple visualization, these figures closely associative, or very interesting.

Crawler re-exploration (v) ——— crawl app data-Super curriculum "three"--date and time analysis

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.