intro to the project

In this project, we'll work with a data set of submissions to popular technology site Hacker News.

You can find the data set here, but note that it has been reduced from almost 300,000 rows to approximately 20,000 rows by removing all submissions that did not receive any comments, and then randomly sampling from the remaining submissions. Below are descriptions of the columns:

  • title: title of the post (self explanatory)

  • url: the url of the item being linked to

  • num_points: the number of upvotes the post received

  • num_comments: the number of comments the post received

  • author: the name of the account that made the post

  • created_at: the date and time the post was made (the time zone is Eastern Time in the US)

In [ ]:
 

reading data and removing headers

In [17]:
# read your data first of all

import csv
read_file = csv.reader(open("HN_posts.csv" , encoding = "utf-8"))
hn = list(read_file)
# removing the header
header = hn[0]
print(header)

# print first 3 rows of your data
hn = hn[1:]
hn[:3]
len(hn)
['id', 'title', 'url', 'num_points', 'num_comments', 'author', 'created_at']
Out[17]:
293119

we are interseted in the Ask HN posts and Show HN

so we will focus on them we will make 3 lists of lists

1-ask_posts

2-show_posts

3-others

In [18]:
# new tip with str.startswith method

s = "fatma"
print(s.startswith("fa"))

print(s.startswith("Fa"))

#use the lower() method returns small case of a string
"Eslam".lower().startswith("e")
True
False
Out[18]:
True
In [19]:
# make 3 lempty lists
ask_posts = []
show_posts = []
other_posts = []

#loop in hn and append each list with its elments
for row in hn:
    title = row[1]
    if title.lower().startswith("ask hn"):
        ask_posts.append(row)
    elif title.lower().startswith("show hn"):
        show_posts.append(row)
    else:
        other_posts.append(row)
In [20]:
print([len(ask_posts) , len(show_posts) , len(other_posts)])
[9139, 10158, 273822]

Calculating the Average Number of Comments for Ask HN and Show HN Posts

In [21]:
# calculate ask_posts avg comments
total_ask_comments = 0
for row in ask_posts:
    total_ask_comments += int(row[4])
    
ask_avg = total_ask_comments / len(ask_posts)
print(ask_avg)
10.393478498741656
In [ ]:
 
In [22]:
# calculate the avg comments for show posts
total_show_comments = 0
for row in show_posts:
    total_show_comments += int(row[4])
    
show_avg = total_show_comments / len(show_posts)
print(show_avg)
4.886099625910612

from the 2 above cells ask_posts recieves more comments than show_posts

we'll focus our remaining analysis just on these posts for ask_posts list

Finding the Amount of Ask Posts and Comments by Hour Created

In [23]:
# create a list of [[time , comments]]
results_list = []

for row in ask_posts:
    created_at = row[6]
    comment = int(row[4])
    results_list.append([created_at , comment])

print(len(results_list)) # the same length as ask_posts 
results_list
9139
Out[23]:
[['9/26/2016 2:53', 7],
 ['9/26/2016 1:17', 3],
 ['9/25/2016 22:57', 0],
 ['9/25/2016 22:48', 3],
 ['9/25/2016 21:50', 2],
 ['9/25/2016 19:30', 1],
 ['9/25/2016 19:22', 22],
 ['9/25/2016 17:55', 3],
 ['9/25/2016 15:48', 0],
 ['9/25/2016 15:35', 13],
 ['9/25/2016 15:28', 0],
 ['9/25/2016 14:43', 0],
 ['9/25/2016 14:17', 3],
 ['9/25/2016 13:08', 2],
 ['9/25/2016 11:27', 2],
 ['9/25/2016 10:51', 0],
 ['9/25/2016 10:47', 6],
 ['9/25/2016 9:04', 97],
 ['9/25/2016 7:09', 4],
 ['9/25/2016 3:00', 1],
 ['9/24/2016 23:04', 0],
 ['9/24/2016 22:02', 7],
 ['9/24/2016 21:18', 2],
 ['9/24/2016 20:58', 0],
 ['9/24/2016 19:57', 1],
 ['9/24/2016 19:02', 0],
 ['9/24/2016 17:55', 0],
 ['9/24/2016 17:27', 1],
 ['9/24/2016 16:50', 0],
 ['9/24/2016 16:03', 5],
 ['9/24/2016 15:29', 66],
 ['9/24/2016 14:03', 1],
 ['9/24/2016 10:10', 11],
 ['9/24/2016 8:46', 7],
 ['9/24/2016 8:39', 1],
 ['9/24/2016 8:38', 1],
 ['9/24/2016 8:28', 1],
 ['9/24/2016 3:36', 3],
 ['9/24/2016 0:21', 2],
 ['9/23/2016 23:38', 6],
 ['9/23/2016 23:35', 6],
 ['9/23/2016 22:13', 4],
 ['9/23/2016 20:58', 2],
 ['9/23/2016 20:42', 0],
 ['9/23/2016 20:23', 1],
 ['9/23/2016 20:18', 477],
 ['9/23/2016 19:33', 3],
 ['9/23/2016 19:32', 10],
 ['9/23/2016 18:56', 12],
 ['9/23/2016 18:53', 4],
 ['9/23/2016 17:45', 1],
 ['9/23/2016 17:35', 1],
 ['9/23/2016 17:28', 25],
 ['9/23/2016 16:56', 2],
 ['9/23/2016 16:14', 3],
 ['9/23/2016 12:39', 6],
 ['9/23/2016 9:58', 1],
 ['9/23/2016 4:47', 2],
 ['9/23/2016 2:28', 3],
 ['9/23/2016 1:56', 8],
 ['9/23/2016 1:24', 2],
 ['9/23/2016 1:23', 1],
 ['9/23/2016 0:58', 0],
 ['9/23/2016 0:11', 5],
 ['9/22/2016 21:45', 3],
 ['9/22/2016 21:19', 5],
 ['9/22/2016 19:58', 19],
 ['9/22/2016 19:42', 6],
 ['9/22/2016 19:40', 23],
 ['9/22/2016 19:18', 2],
 ['9/22/2016 18:16', 1],
 ['9/22/2016 17:43', 0],
 ['9/22/2016 17:38', 0],
 ['9/22/2016 17:27', 0],
 ['9/22/2016 17:27', 26],
 ['9/22/2016 17:05', 0],
 ['9/22/2016 16:34', 0],
 ['9/22/2016 15:44', 1],
 ['9/22/2016 15:18', 10],
 ['9/22/2016 15:18', 1],
 ['9/22/2016 14:49', 62],
 ['9/22/2016 13:11', 0],
 ['9/22/2016 12:58', 0],
 ['9/22/2016 12:55', 0],
 ['9/22/2016 12:50', 3],
 ['9/22/2016 11:52', 266],
 ['9/22/2016 6:25', 1],
 ['9/22/2016 6:19', 2],
 ['9/22/2016 5:03', 0],
 ['9/22/2016 4:55', 0],
 ['9/22/2016 0:47', 0],
 ['9/21/2016 23:37', 0],
 ['9/21/2016 23:03', 22],
 ['9/21/2016 21:14', 1],
 ['9/21/2016 20:53', 6],
 ['9/21/2016 20:35', 1],
 ['9/21/2016 20:33', 1],
 ['9/21/2016 19:30', 1],
 ['9/21/2016 19:18', 46],
 ['9/21/2016 18:39', 0],
 ['9/21/2016 18:11', 2],
 ['9/21/2016 17:56', 5],
 ['9/21/2016 17:46', 23],
 ['9/21/2016 17:36', 0],
 ['9/21/2016 17:24', 0],
 ['9/21/2016 14:50', 62],
 ['9/21/2016 14:35', 2],
 ['9/21/2016 13:49', 2],
 ['9/21/2016 13:42', 61],
 ['9/21/2016 12:24', 1],
 ['9/21/2016 12:17', 4],
 ['9/21/2016 12:00', 2],
 ['9/21/2016 11:28', 0],
 ['9/21/2016 10:41', 0],
 ['9/21/2016 9:49', 1],
 ['9/21/2016 8:26', 1],
 ['9/21/2016 8:16', 2],
 ['9/21/2016 7:12', 10],
 ['9/21/2016 5:27', 0],
 ['9/21/2016 4:58', 2],
 ['9/21/2016 4:02', 1],
 ['9/21/2016 2:45', 94],
 ['9/21/2016 2:36', 30],
 ['9/21/2016 0:38', 1],
 ['9/21/2016 0:31', 1],
 ['9/20/2016 23:20', 3],
 ['9/20/2016 22:48', 20],
 ['9/20/2016 21:41', 14],
 ['9/20/2016 21:07', 12],
 ['9/20/2016 21:00', 30],
 ['9/20/2016 20:37', 2],
 ['9/20/2016 19:39', 7],
 ['9/20/2016 19:20', 1],
 ['9/20/2016 18:45', 7],
 ['9/20/2016 18:37', 1],
 ['9/20/2016 18:30', 0],
 ['9/20/2016 18:20', 3],
 ['9/20/2016 17:41', 11],
 ['9/20/2016 17:32', 3],
 ['9/20/2016 16:35', 1],
 ['9/20/2016 16:17', 20],
 ['9/20/2016 16:08', 8],
 ['9/20/2016 15:30', 3],
 ['9/20/2016 14:54', 0],
 ['9/20/2016 14:42', 4],
 ['9/20/2016 14:22', 2],
 ['9/20/2016 14:21', 0],
 ['9/20/2016 12:11', 1],
 ['9/20/2016 12:09', 2],
 ['9/20/2016 11:29', 4],
 ['9/20/2016 11:23', 7],
 ['9/20/2016 11:02', 2],
 ['9/20/2016 8:32', 0],
 ['9/20/2016 8:03', 2],
 ['9/20/2016 7:20', 0],
 ['9/20/2016 6:43', 3],
 ['9/20/2016 6:04', 4],
 ['9/20/2016 5:13', 3],
 ['9/20/2016 5:07', 0],
 ['9/19/2016 23:55', 10],
 ['9/19/2016 23:31', 59],
 ['9/19/2016 22:50', 5],
 ['9/19/2016 21:48', 1],
 ['9/19/2016 21:42', 3],
 ['9/19/2016 21:19', 1],
 ['9/19/2016 19:57', 0],
 ['9/19/2016 19:40', 1],
 ['9/19/2016 19:21', 28],
 ['9/19/2016 19:04', 2],
 ['9/19/2016 18:55', 0],
 ['9/19/2016 18:51', 14],
 ['9/19/2016 18:28', 2],
 ['9/19/2016 18:23', 0],
 ['9/19/2016 18:16', 0],
 ['9/19/2016 16:40', 0],
 ['9/19/2016 16:04', 2],
 ['9/19/2016 15:57', 1],
 ['9/19/2016 15:54', 0],
 ['9/19/2016 15:51', 7],
 ['9/19/2016 15:31', 2],
 ['9/19/2016 15:15', 0],
 ['9/19/2016 14:43', 6],
 ['9/19/2016 14:36', 10],
 ['9/19/2016 14:21', 1],
 ['9/19/2016 13:40', 11],
 ['9/19/2016 12:54', 2],
 ['9/19/2016 9:45', 7],
 ['9/19/2016 9:42', 1],
 ['9/19/2016 8:31', 2],
 ['9/19/2016 7:44', 22],
 ['9/19/2016 6:06', 73],
 ['9/19/2016 2:07', 14],
 ['9/19/2016 0:16', 61],
 ['9/18/2016 23:05', 1],
 ['9/18/2016 18:35', 0],
 ['9/18/2016 18:33', 9],
 ['9/18/2016 17:30', 0],
 ['9/18/2016 17:28', 2],
 ['9/18/2016 16:24', 0],
 ['9/18/2016 16:05', 1],
 ['9/18/2016 15:51', 1],
 ['9/18/2016 15:24', 4],
 ['9/18/2016 14:48', 0],
 ['9/18/2016 14:20', 1],
 ['9/18/2016 8:58', 0],
 ['9/18/2016 5:41', 1],
 ['9/18/2016 3:40', 35],
 ['9/18/2016 3:38', 2],
 ['9/18/2016 2:20', 0],
 ['9/17/2016 23:48', 6],
 ['9/17/2016 23:40', 4],
 ['9/17/2016 22:23', 0],
 ['9/17/2016 21:18', 2],
 ['9/17/2016 19:01', 5],
 ['9/17/2016 18:47', 10],
 ['9/17/2016 18:34', 23],
 ['9/17/2016 18:16', 2],
 ['9/17/2016 17:43', 4],
 ['9/17/2016 16:36', 5],
 ['9/17/2016 16:07', 0],
 ['9/17/2016 15:58', 1],
 ['9/17/2016 15:58', 4],
 ['9/17/2016 15:44', 35],
 ['9/17/2016 15:02', 0],
 ['9/17/2016 13:03', 25],
 ['9/17/2016 10:35', 1],
 ['9/17/2016 10:17', 10],
 ['9/17/2016 9:57', 1],
 ['9/17/2016 8:41', 14],
 ['9/17/2016 7:34', 1],
 ['9/17/2016 6:35', 6],
 ['9/17/2016 4:07', 19],
 ['9/17/2016 3:48', 1],
 ['9/17/2016 2:00', 0],
 ['9/17/2016 1:06', 9],
 ['9/16/2016 22:56', 33],
 ['9/16/2016 22:56', 39],
 ['9/16/2016 22:09', 2],
 ['9/16/2016 21:39', 3],
 ['9/16/2016 21:19', 2],
 ['9/16/2016 21:02', 0],
 ['9/16/2016 20:51', 14],
 ['9/16/2016 20:51', 40],
 ['9/16/2016 20:28', 1],
 ['9/16/2016 19:46', 0],
 ['9/16/2016 19:28', 185],
 ['9/16/2016 19:00', 25],
 ['9/16/2016 18:14', 2],
 ['9/16/2016 18:11', 0],
 ['9/16/2016 18:08', 1],
 ['9/16/2016 18:04', 0],
 ['9/16/2016 17:56', 5],
 ['9/16/2016 16:38', 1],
 ['9/16/2016 15:59', 0],
 ['9/16/2016 15:47', 0],
 ['9/16/2016 14:39', 5],
 ['9/16/2016 13:43', 6],
 ['9/16/2016 13:16', 2],
 ['9/16/2016 12:06', 0],
 ['9/16/2016 11:47', 1],
 ['9/16/2016 11:46', 5],
 ['9/16/2016 10:49', 36],
 ['9/16/2016 9:31', 5],
 ['9/16/2016 8:32', 6],
 ['9/16/2016 8:29', 0],
 ['9/16/2016 8:26', 2],
 ['9/16/2016 6:49', 1],
 ['9/16/2016 6:06', 2],
 ['9/16/2016 5:55', 2],
 ['9/16/2016 4:56', 2],
 ['9/16/2016 3:54', 2],
 ['9/15/2016 22:42', 9],
 ['9/15/2016 22:34', 0],
 ['9/15/2016 22:09', 1],
 ['9/15/2016 21:09', 1],
 ['9/15/2016 21:07', 4],
 ['9/15/2016 21:01', 0],
 ['9/15/2016 20:54', 1],
 ['9/15/2016 19:58', 0],
 ['9/15/2016 19:50', 9],
 ['9/15/2016 19:22', 0],
 ['9/15/2016 18:30', 1],
 ['9/15/2016 18:26', 6],
 ['9/15/2016 17:57', 1],
 ['9/15/2016 17:00', 0],
 ['9/15/2016 16:36', 8],
 ['9/15/2016 16:30', 11],
 ['9/15/2016 16:28', 2],
 ['9/15/2016 16:27', 9],
 ['9/15/2016 16:03', 3],
 ['9/15/2016 15:45', 0],
 ['9/15/2016 15:27', 1],
 ['9/15/2016 15:04', 2],
 ['9/15/2016 14:52', 1],
 ['9/15/2016 14:17', 1],
 ['9/15/2016 14:15', 0],
 ['9/15/2016 13:51', 7],
 ['9/15/2016 13:50', 1],
 ['9/15/2016 13:46', 1],
 ['9/15/2016 13:21', 0],
 ['9/15/2016 12:45', 1],
 ['9/15/2016 12:00', 55],
 ['9/15/2016 9:17', 2],
 ['9/15/2016 8:40', 2],
 ['9/15/2016 7:49', 0],
 ['9/15/2016 7:30', 0],
 ['9/15/2016 7:14', 1],
 ['9/15/2016 7:11', 3],
 ['9/15/2016 6:07', 3],
 ['9/15/2016 6:06', 0],
 ['9/15/2016 3:23', 1],
 ['9/15/2016 2:04', 0],
 ['9/15/2016 1:34', 0],
 ['9/15/2016 1:11', 2],
 ['9/15/2016 0:12', 1],
 ['9/14/2016 23:28', 4],
 ['9/14/2016 23:26', 0],
 ['9/14/2016 22:39', 2],
 ['9/14/2016 22:32', 0],
 ['9/14/2016 20:54', 1],
 ['9/14/2016 20:46', 1],
 ['9/14/2016 20:19', 2],
 ['9/14/2016 20:19', 4],
 ['9/14/2016 18:32', 0],
 ['9/14/2016 18:08', 0],
 ['9/14/2016 18:02', 27],
 ['9/14/2016 17:55', 0],
 ['9/14/2016 17:52', 0],
 ['9/14/2016 17:45', 1],
 ['9/14/2016 17:29', 0],
 ['9/14/2016 17:11', 0],
 ['9/14/2016 17:06', 0],
 ['9/14/2016 16:42', 1],
 ['9/14/2016 15:27', 34],
 ['9/14/2016 15:23', 0],
 ['9/14/2016 15:10', 4],
 ['9/14/2016 15:09', 0],
 ['9/14/2016 14:55', 0],
 ['9/14/2016 14:32', 6],
 ['9/14/2016 14:31', 5],
 ['9/14/2016 14:22', 1],
 ['9/14/2016 14:21', 1],
 ['9/14/2016 13:20', 138],
 ['9/14/2016 13:17', 7],
 ['9/14/2016 10:57', 1],
 ['9/14/2016 10:13', 1],
 ['9/14/2016 9:05', 75],
 ['9/14/2016 7:02', 0],
 ['9/14/2016 5:54', 1],
 ['9/14/2016 1:50', 2],
 ['9/14/2016 0:09', 2],
 ['9/13/2016 22:07', 14],
 ['9/13/2016 21:43', 1],
 ['9/13/2016 21:27', 3],
 ['9/13/2016 21:15', 3],
 ['9/13/2016 21:09', 1],
 ['9/13/2016 20:48', 17],
 ['9/13/2016 19:26', 0],
 ['9/13/2016 18:21', 7],
 ['9/13/2016 17:51', 5],
 ['9/13/2016 17:16', 2],
 ['9/13/2016 16:36', 26],
 ['9/13/2016 16:22', 0],
 ['9/13/2016 15:25', 1],
 ['9/13/2016 14:59', 4],
 ['9/13/2016 13:57', 31],
 ['9/13/2016 13:44', 0],
 ['9/13/2016 13:07', 1],
 ['9/13/2016 11:55', 4],
 ['9/13/2016 11:49', 2],
 ['9/13/2016 11:47', 8],
 ['9/13/2016 11:19', 35],
 ['9/13/2016 11:04', 0],
 ['9/13/2016 10:48', 3],
 ['9/13/2016 10:16', 3],
 ['9/13/2016 9:14', 1],
 ['9/13/2016 8:10', 1],
 ['9/13/2016 8:02', 1],
 ['9/13/2016 8:01', 0],
 ['9/13/2016 6:25', 2],
 ['9/13/2016 4:42', 5],
 ['9/13/2016 3:50', 1],
 ['9/13/2016 3:46', 2],
 ['9/13/2016 3:28', 0],
 ['9/13/2016 2:52', 2],
 ['9/13/2016 2:51', 5],
 ['9/13/2016 2:15', 11],
 ['9/13/2016 1:58', 1],
 ['9/13/2016 1:09', 3],
 ['9/13/2016 0:39', 18],
 ['9/13/2016 0:36', 2],
 ['9/12/2016 23:57', 1],
 ['9/12/2016 21:26', 43],
 ['9/12/2016 20:29', 0],
 ['9/12/2016 20:28', 4],
 ['9/12/2016 19:25', 3],
 ['9/12/2016 19:05', 1],
 ['9/12/2016 18:29', 0],
 ['9/12/2016 18:19', 3],
 ['9/12/2016 18:07', 22],
 ['9/12/2016 17:59', 0],
 ['9/12/2016 17:22', 3],
 ['9/12/2016 17:16', 0],
 ['9/12/2016 16:52', 7],
 ['9/12/2016 16:51', 1],
 ['9/12/2016 15:28', 0],
 ['9/12/2016 14:52', 3],
 ['9/12/2016 13:23', 1],
 ['9/12/2016 13:19', 0],
 ['9/12/2016 13:18', 0],
 ['9/12/2016 12:58', 1],
 ['9/12/2016 12:50', 1],
 ['9/12/2016 12:39', 0],
 ['9/12/2016 12:04', 3],
 ['9/12/2016 10:50', 9],
 ['9/12/2016 8:33', 45],
 ['9/12/2016 7:47', 5],
 ['9/12/2016 7:39', 61],
 ['9/12/2016 6:26', 3],
 ['9/12/2016 5:57', 7],
 ['9/12/2016 4:38', 21],
 ['9/12/2016 4:29', 660],
 ['9/12/2016 3:33', 3],
 ['9/12/2016 2:39', 106],
 ['9/11/2016 22:09', 2],
 ['9/11/2016 19:31', 75],
 ['9/11/2016 18:47', 6],
 ['9/11/2016 18:09', 1],
 ['9/11/2016 17:54', 2],
 ['9/11/2016 15:17', 0],
 ['9/11/2016 15:03', 42],
 ['9/11/2016 12:26', 0],
 ['9/11/2016 5:47', 2],
 ['9/11/2016 5:43', 2],
 ['9/11/2016 5:09', 1],
 ['9/11/2016 4:25', 6],
 ['9/11/2016 2:39', 0],
 ['9/11/2016 1:28', 1],
 ['9/11/2016 0:50', 3],
 ['9/11/2016 0:20', 6],
 ['9/10/2016 23:39', 9],
 ['9/10/2016 23:08', 18],
 ['9/10/2016 22:30', 0],
 ['9/10/2016 22:19', 16],
 ['9/10/2016 21:18', 25],
 ['9/10/2016 21:01', 4],
 ['9/10/2016 20:57', 2],
 ['9/10/2016 18:05', 1],
 ['9/10/2016 17:48', 6],
 ['9/10/2016 16:01', 5],
 ['9/10/2016 14:56', 6],
 ['9/10/2016 14:31', 30],
 ['9/10/2016 13:38', 3],
 ['9/10/2016 12:24', 1],
 ['9/10/2016 12:11', 0],
 ['9/10/2016 10:13', 2],
 ['9/10/2016 9:07', 3],
 ['9/10/2016 8:39', 0],
 ['9/10/2016 8:07', 5],
 ['9/10/2016 7:49', 7],
 ['9/10/2016 3:44', 0],
 ['9/10/2016 2:33', 4],
 ['9/10/2016 1:58', 4],
 ['9/10/2016 0:17', 4],
 ['9/9/2016 20:25', 0],
 ['9/9/2016 20:10', 0],
 ['9/9/2016 20:09', 5],
 ['9/9/2016 19:42', 0],
 ['9/9/2016 18:51', 0],
 ['9/9/2016 18:40', 10],
 ['9/9/2016 16:59', 1],
 ['9/9/2016 16:41', 2],
 ['9/9/2016 15:16', 0],
 ['9/9/2016 14:20', 0],
 ['9/9/2016 13:25', 0],
 ['9/9/2016 12:46', 1],
 ['9/9/2016 12:36', 15],
 ['9/9/2016 12:35', 1],
 ['9/9/2016 11:08', 1],
 ['9/9/2016 10:54', 33],
 ['9/9/2016 10:10', 0],
 ['9/9/2016 10:09', 2],
 ['9/9/2016 10:03', 1],
 ['9/9/2016 6:59', 0],
 ['9/9/2016 3:32', 18],
 ['9/9/2016 0:14', 10],
 ['9/8/2016 23:52', 3],
 ['9/8/2016 23:32', 3],
 ['9/8/2016 23:23', 1],
 ['9/8/2016 21:27', 0],
 ['9/8/2016 20:16', 0],
 ['9/8/2016 19:35', 39],
 ['9/8/2016 18:20', 2],
 ['9/8/2016 17:57', 5],
 ['9/8/2016 17:53', 18],
 ['9/8/2016 17:47', 0],
 ['9/8/2016 17:45', 4],
 ['9/8/2016 16:53', 2],
 ['9/8/2016 15:42', 1],
 ['9/8/2016 15:18', 1],
 ['9/8/2016 15:09', 3],
 ['9/8/2016 14:39', 2],
 ['9/8/2016 13:06', 0],
 ['9/8/2016 13:05', 1],
 ['9/8/2016 12:58', 35],
 ['9/8/2016 11:23', 2],
 ['9/8/2016 10:45', 3],
 ['9/8/2016 10:28', 10],
 ['9/8/2016 10:18', 5],
 ['9/8/2016 6:34', 0],
 ['9/8/2016 3:32', 3],
 ['9/8/2016 0:50', 0],
 ['9/8/2016 0:37', 3],
 ['9/8/2016 0:10', 15],
 ['9/7/2016 23:57', 3],
 ['9/7/2016 22:53', 1],
 ['9/7/2016 22:48', 3],
 ['9/7/2016 22:14', 4],
 ['9/7/2016 21:27', 0],
 ['9/7/2016 21:16', 7],
 ['9/7/2016 20:28', 7],
 ['9/7/2016 20:27', 3],
 ['9/7/2016 20:15', 5],
 ['9/7/2016 20:03', 0],
 ['9/7/2016 18:44', 0],
 ['9/7/2016 18:33', 2],
 ['9/7/2016 16:11', 5],
 ['9/7/2016 15:57', 0],
 ['9/7/2016 15:49', 3],
 ['9/7/2016 15:26', 14],
 ['9/7/2016 14:12', 0],
 ['9/7/2016 13:17', 0],
 ['9/7/2016 12:20', 0],
 ['9/7/2016 11:37', 4],
 ['9/7/2016 11:32', 1],
 ['9/7/2016 11:14', 3],
 ['9/7/2016 11:02', 6],
 ['9/7/2016 10:43', 4],
 ['9/7/2016 9:40', 1],
 ['9/7/2016 8:31', 5],
 ['9/7/2016 8:31', 3],
 ['9/7/2016 2:21', 6],
 ['9/7/2016 2:12', 1],
 ['9/7/2016 2:11', 11],
 ['9/7/2016 1:47', 35],
 ['9/7/2016 1:34', 4],
 ['9/7/2016 1:18', 3],
 ['9/7/2016 1:02', 5],
 ['9/6/2016 23:45', 0],
 ['9/6/2016 22:59', 5],
 ['9/6/2016 22:59', 3],
 ['9/6/2016 22:18', 65],
 ['9/6/2016 21:02', 3],
 ['9/6/2016 20:15', 1],
 ['9/6/2016 17:23', 0],
 ['9/6/2016 17:22', 7],
 ['9/6/2016 17:11', 10],
 ['9/6/2016 16:45', 9],
 ['9/6/2016 15:52', 0],
 ['9/6/2016 15:26', 1],
 ['9/6/2016 15:02', 0],
 ['9/6/2016 14:16', 0],
 ['9/6/2016 13:36', 43],
 ['9/6/2016 13:08', 0],
 ['9/6/2016 12:57', 2],
 ['9/6/2016 12:53', 7],
 ['9/6/2016 12:03', 6],
 ['9/6/2016 10:11', 0],
 ['9/6/2016 10:10', 0],
 ['9/6/2016 9:58', 0],
 ['9/6/2016 9:51', 9],
 ['9/6/2016 9:14', 0],
 ['9/6/2016 6:08', 2],
 ['9/5/2016 22:31', 0],
 ['9/5/2016 20:01', 1],
 ['9/5/2016 19:48', 0],
 ['9/5/2016 19:13', 1],
 ['9/5/2016 19:08', 0],
 ['9/5/2016 18:36', 3],
 ['9/5/2016 17:58', 0],
 ['9/5/2016 17:15', 0],
 ['9/5/2016 15:10', 2],
 ['9/5/2016 13:56', 5],
 ['9/5/2016 13:45', 4],
 ['9/5/2016 13:19', 1],
 ['9/5/2016 12:34', 1],
 ['9/5/2016 12:13', 4],
 ['9/5/2016 11:13', 5],
 ['9/5/2016 11:06', 4],
 ['9/5/2016 10:08', 2],
 ['9/5/2016 9:32', 2],
 ['9/5/2016 9:06', 3],
 ['9/5/2016 8:35', 4],
 ['9/5/2016 7:27', 39],
 ['9/5/2016 7:12', 2],
 ['9/5/2016 6:58', 40],
 ['9/5/2016 6:19', 1],
 ['9/5/2016 5:36', 85],
 ['9/5/2016 3:04', 39],
 ['9/5/2016 2:45', 1],
 ['9/5/2016 2:41', 0],
 ['9/5/2016 1:42', 2],
 ['9/5/2016 1:40', 2],
 ['9/4/2016 21:48', 0],
 ['9/4/2016 21:34', 6],
 ['9/4/2016 21:26', 39],
 ['9/4/2016 21:17', 47],
 ['9/4/2016 20:41', 0],
 ['9/4/2016 19:57', 2],
 ['9/4/2016 19:29', 5],
 ['9/4/2016 18:23', 1],
 ['9/4/2016 17:53', 0],
 ['9/4/2016 17:48', 6],
 ['9/4/2016 17:33', 5],
 ['9/4/2016 16:55', 0],
 ['9/4/2016 16:46', 1],
 ['9/4/2016 16:18', 0],
 ['9/4/2016 15:09', 3],
 ['9/4/2016 14:17', 3],
 ['9/4/2016 14:15', 0],
 ['9/4/2016 13:54', 1],
 ['9/4/2016 13:50', 1],
 ['9/4/2016 13:41', 84],
 ['9/4/2016 13:36', 3],
 ['9/4/2016 13:34', 34],
 ['9/4/2016 12:59', 3],
 ['9/4/2016 12:26', 3],
 ['9/4/2016 11:34', 1],
 ['9/4/2016 9:54', 1],
 ['9/4/2016 8:31', 6],
 ['9/4/2016 7:43', 130],
 ['9/4/2016 5:41', 3],
 ['9/4/2016 5:09', 6],
 ['9/4/2016 3:02', 9],
 ['9/4/2016 2:57', 1],
 ['9/4/2016 0:00', 110],
 ['9/3/2016 23:16', 3],
 ['9/3/2016 20:25', 1],
 ['9/3/2016 19:59', 6],
 ['9/3/2016 19:01', 4],
 ['9/3/2016 18:45', 1],
 ['9/3/2016 17:25', 6],
 ['9/3/2016 17:05', 5],
 ['9/3/2016 16:14', 3],
 ['9/3/2016 16:10', 75],
 ['9/3/2016 15:32', 3],
 ['9/3/2016 14:31', 5],
 ['9/3/2016 12:02', 4],
 ['9/3/2016 10:58', 34],
 ['9/3/2016 10:06', 3],
 ['9/3/2016 9:02', 0],
 ['9/3/2016 1:50', 1],
 ['9/2/2016 23:53', 6],
 ['9/2/2016 22:27', 0],
 ['9/2/2016 22:03', 38],
 ['9/2/2016 21:59', 0],
 ['9/2/2016 21:30', 0],
 ['9/2/2016 19:56', 6],
 ['9/2/2016 19:31', 105],
 ['9/2/2016 18:52', 1],
 ['9/2/2016 18:19', 4],
 ['9/2/2016 18:10', 49],
 ['9/2/2016 17:57', 3],
 ['9/2/2016 16:37', 4],
 ['9/2/2016 15:04', 0],
 ['9/2/2016 14:24', 2],
 ['9/2/2016 14:13', 1],
 ['9/2/2016 14:13', 0],
 ['9/2/2016 13:58', 1],
 ['9/2/2016 13:35', 0],
 ['9/2/2016 13:29', 0],
 ['9/2/2016 12:55', 223],
 ['9/2/2016 12:41', 0],
 ['9/2/2016 10:48', 2],
 ['9/2/2016 6:32', 0],
 ['9/2/2016 5:18', 1],
 ['9/2/2016 4:39', 13],
 ['9/2/2016 4:21', 1],
 ['9/2/2016 2:08', 8],
 ['9/2/2016 2:05', 8],
 ['9/2/2016 2:03', 0],
 ['9/1/2016 21:34', 4],
 ['9/1/2016 20:23', 32],
 ['9/1/2016 16:27', 3],
 ['9/1/2016 15:59', 0],
 ['9/1/2016 15:00', 37],
 ['9/1/2016 15:00', 166],
 ['9/1/2016 15:00', 85],
 ['9/1/2016 15:00', 910],
 ['9/1/2016 14:37', 8],
 ['9/1/2016 14:21', 0],
 ['9/1/2016 14:17', 0],
 ['9/1/2016 14:00', 2],
 ['9/1/2016 13:20', 0],
 ['9/1/2016 12:25', 4],
 ['9/1/2016 12:23', 1],
 ['9/1/2016 12:22', 1],
 ['9/1/2016 12:09', 2],
 ['9/1/2016 11:27', 0],
 ['9/1/2016 10:48', 2],
 ['9/1/2016 9:58', 3],
 ['9/1/2016 9:44', 2],
 ['9/1/2016 8:36', 4],
 ['9/1/2016 8:16', 1],
 ['9/1/2016 7:39', 0],
 ['9/1/2016 4:48', 2],
 ['9/1/2016 4:31', 2],
 ['9/1/2016 3:09', 10],
 ['9/1/2016 2:40', 0],
 ['9/1/2016 1:13', 6],
 ['9/1/2016 0:14', 1],
 ['8/31/2016 23:14', 8],
 ['8/31/2016 22:51', 2],
 ['8/31/2016 20:13', 3],
 ['8/31/2016 19:56', 3],
 ['8/31/2016 19:45', 6],
 ['8/31/2016 18:39', 0],
 ['8/31/2016 18:34', 0],
 ['8/31/2016 18:26', 0],
 ['8/31/2016 18:21', 9],
 ['8/31/2016 18:20', 0],
 ['8/31/2016 18:09', 0],
 ['8/31/2016 16:54', 8],
 ['8/31/2016 16:29', 11],
 ['8/31/2016 16:21', 3],
 ['8/31/2016 16:01', 17],
 ['8/31/2016 15:42', 0],
 ['8/31/2016 13:55', 172],
 ['8/31/2016 11:41', 6],
 ['8/31/2016 11:25', 4],
 ['8/31/2016 10:39', 3],
 ['8/31/2016 9:47', 1],
 ['8/31/2016 9:20', 0],
 ['8/31/2016 8:46', 93],
 ['8/31/2016 7:31', 0],
 ['8/31/2016 7:22', 5],
 ['8/31/2016 7:21', 4],
 ['8/31/2016 3:48', 2],
 ['8/31/2016 2:20', 27],
 ['8/31/2016 1:23', 5],
 ['8/31/2016 1:00', 11],
 ['8/31/2016 0:30', 0],
 ['8/30/2016 23:50', 0],
 ['8/30/2016 21:56', 10],
 ['8/30/2016 21:11', 6],
 ['8/30/2016 20:57', 6],
 ['8/30/2016 20:46', 9],
 ['8/30/2016 20:45', 82],
 ['8/30/2016 20:32', 4],
 ['8/30/2016 20:31', 0],
 ['8/30/2016 20:09', 5],
 ['8/30/2016 19:36', 0],
 ['8/30/2016 19:34', 3],
 ['8/30/2016 19:28', 10],
 ['8/30/2016 19:17', 4],
 ['8/30/2016 18:38', 0],
 ['8/30/2016 18:08', 0],
 ['8/30/2016 18:01', 0],
 ['8/30/2016 16:40', 6],
 ['8/30/2016 16:09', 12],
 ['8/30/2016 15:33', 2],
 ['8/30/2016 15:27', 9],
 ['8/30/2016 15:18', 1],
 ['8/30/2016 14:54', 0],
 ['8/30/2016 14:48', 22],
 ['8/30/2016 13:53', 2],
 ['8/30/2016 13:00', 30],
 ['8/30/2016 12:56', 0],
 ['8/30/2016 12:56', 2],
 ['8/30/2016 12:43', 6],
 ['8/30/2016 12:29', 2],
 ['8/30/2016 12:25', 1],
 ['8/30/2016 11:58', 1],
 ['8/30/2016 11:20', 4],
 ['8/30/2016 11:08', 15],
 ['8/30/2016 10:26', 1],
 ['8/30/2016 8:28', 1],
 ['8/30/2016 7:53', 0],
 ['8/30/2016 5:57', 11],
 ['8/30/2016 5:18', 8],
 ['8/30/2016 4:43', 0],
 ['8/30/2016 4:25', 1],
 ['8/30/2016 2:44', 1],
 ['8/30/2016 2:42', 17],
 ['8/30/2016 2:14', 1],
 ['8/30/2016 0:49', 3],
 ['8/29/2016 22:13', 5],
 ['8/29/2016 22:12', 3],
 ['8/29/2016 21:50', 1],
 ['8/29/2016 21:31', 1],
 ['8/29/2016 21:19', 2],
 ['8/29/2016 20:47', 0],
 ['8/29/2016 19:35', 0],
 ['8/29/2016 19:33', 2],
 ['8/29/2016 19:27', 0],
 ['8/29/2016 18:31', 0],
 ['8/29/2016 18:26', 4],
 ['8/29/2016 18:07', 3],
 ['8/29/2016 17:16', 1],
 ['8/29/2016 16:41', 5],
 ['8/29/2016 16:08', 0],
 ['8/29/2016 15:57', 51],
 ['8/29/2016 15:22', 0],
 ['8/29/2016 15:07', 2],
 ['8/29/2016 14:31', 52],
 ['8/29/2016 13:15', 13],
 ['8/29/2016 13:13', 6],
 ['8/29/2016 13:03', 8],
 ['8/29/2016 13:01', 0],
 ['8/29/2016 12:20', 2],
 ['8/29/2016 11:48', 0],
 ['8/29/2016 10:25', 0],
 ['8/29/2016 10:20', 4],
 ['8/29/2016 9:18', 9],
 ['8/29/2016 8:36', 5],
 ['8/29/2016 8:23', 0],
 ['8/29/2016 7:56', 4],
 ['8/29/2016 0:07', 1],
 ['8/28/2016 23:46', 57],
 ['8/28/2016 23:40', 0],
 ['8/28/2016 21:24', 2],
 ['8/28/2016 20:38', 4],
 ['8/28/2016 20:16', 2],
 ['8/28/2016 20:05', 0],
 ['8/28/2016 18:58', 3],
 ['8/28/2016 18:24', 6],
 ['8/28/2016 18:06', 2],
 ['8/28/2016 17:42', 1],
 ['8/28/2016 16:58', 5],
 ['8/28/2016 15:40', 2],
 ['8/28/2016 14:41', 3],
 ['8/28/2016 14:34', 7],
 ['8/28/2016 14:16', 106],
 ['8/28/2016 12:33', 221],
 ['8/28/2016 11:07', 2],
 ['8/28/2016 10:13', 3],
 ['8/28/2016 7:11', 0],
 ['8/28/2016 6:18', 1],
 ['8/28/2016 5:24', 1],
 ['8/28/2016 5:19', 5],
 ['8/28/2016 4:22', 8],
 ['8/28/2016 2:00', 4],
 ['8/28/2016 1:00', 9],
 ['8/28/2016 0:03', 1],
 ['8/27/2016 23:52', 10],
 ['8/27/2016 22:29', 88],
 ['8/27/2016 21:36', 6],
 ['8/27/2016 20:09', 3],
 ['8/27/2016 19:42', 3],
 ['8/27/2016 19:38', 5],
 ['8/27/2016 19:31', 93],
 ['8/27/2016 19:03', 2],
 ['8/27/2016 18:05', 11],
 ['8/27/2016 17:07', 1],
 ['8/27/2016 15:21', 3],
 ['8/27/2016 13:20', 1],
 ['8/27/2016 13:15', 5],
 ['8/27/2016 12:09', 5],
 ['8/27/2016 11:44', 4],
 ['8/27/2016 11:33', 21],
 ['8/27/2016 10:25', 3],
 ['8/27/2016 8:42', 0],
 ['8/27/2016 6:19', 7],
 ['8/27/2016 5:56', 2],
 ['8/27/2016 2:53', 0],
 ['8/27/2016 1:47', 2],
 ['8/27/2016 0:57', 2],
 ['8/26/2016 22:56', 1],
 ['8/26/2016 22:38', 0],
 ['8/26/2016 20:54', 3],
 ['8/26/2016 20:22', 5],
 ['8/26/2016 19:25', 15],
 ['8/26/2016 16:10', 2],
 ['8/26/2016 15:39', 1],
 ['8/26/2016 15:36', 0],
 ['8/26/2016 15:23', 15],
 ['8/26/2016 15:08', 0],
 ['8/26/2016 15:07', 0],
 ['8/26/2016 14:28', 1],
 ['8/26/2016 14:12', 3],
 ['8/26/2016 10:01', 1],
 ['8/26/2016 9:44', 2],
 ['8/26/2016 8:39', 24],
 ['8/26/2016 6:57', 1],
 ['8/26/2016 6:35', 0],
 ['8/26/2016 3:48', 0],
 ['8/26/2016 2:19', 6],
 ['8/26/2016 1:54', 10],
 ['8/26/2016 1:39', 7],
 ['8/26/2016 0:49', 1],
 ['8/25/2016 21:49', 5],
 ['8/25/2016 21:16', 0],
 ['8/25/2016 21:11', 8],
 ['8/25/2016 20:04', 0],
 ['8/25/2016 18:53', 0],
 ['8/25/2016 17:43', 12],
 ['8/25/2016 17:37', 5],
 ['8/25/2016 16:00', 3],
 ['8/25/2016 15:31', 10],
 ['8/25/2016 15:18', 1],
 ['8/25/2016 15:07', 59],
 ['8/25/2016 14:51', 1],
 ['8/25/2016 14:36', 0],
 ['8/25/2016 13:58', 0],
 ['8/25/2016 12:47', 2],
 ['8/25/2016 12:22', 8],
 ['8/25/2016 11:20', 6],
 ['8/25/2016 10:49', 2],
 ['8/25/2016 10:03', 2],
 ['8/25/2016 9:59', 1],
 ['8/25/2016 7:33', 5],
 ['8/25/2016 7:12', 2],
 ['8/25/2016 6:59', 7],
 ['8/25/2016 5:35', 7],
 ['8/25/2016 4:48', 0],
 ['8/25/2016 3:35', 2],
 ['8/25/2016 1:54', 2],
 ['8/25/2016 1:17', 42],
 ['8/24/2016 23:54', 1],
 ['8/24/2016 22:41', 10],
 ['8/24/2016 22:34', 2],
 ['8/24/2016 22:04', 6],
 ['8/24/2016 21:52', 6],
 ['8/24/2016 21:16', 0],
 ['8/24/2016 21:02', 9],
 ['8/24/2016 20:27', 1],
 ['8/24/2016 19:50', 0],
 ['8/24/2016 18:41', 1],
 ['8/24/2016 17:38', 1],
 ['8/24/2016 16:31', 0],
 ['8/24/2016 16:11', 0],
 ['8/24/2016 16:03', 2],
 ['8/24/2016 15:23', 2],
 ['8/24/2016 14:48', 2],
 ['8/24/2016 14:10', 0],
 ['8/24/2016 13:54', 0],
 ['8/24/2016 12:09', 1],
 ['8/24/2016 12:07', 2],
 ['8/24/2016 11:54', 26],
 ['8/24/2016 10:50', 10],
 ['8/24/2016 9:57', 83],
 ['8/24/2016 8:11', 0],
 ['8/24/2016 6:48', 0],
 ['8/24/2016 6:17', 1],
 ['8/24/2016 5:56', 0],
 ['8/24/2016 3:41', 5],
 ['8/24/2016 2:35', 1],
 ['8/24/2016 2:15', 23],
 ['8/24/2016 2:03', 2],
 ['8/24/2016 0:05', 234],
 ['8/23/2016 23:22', 6],
 ['8/23/2016 21:56', 1],
 ['8/23/2016 21:02', 3],
 ['8/23/2016 20:46', 0],
 ['8/23/2016 20:00', 2],
 ['8/23/2016 19:11', 2],
 ['8/23/2016 19:05', 1],
 ['8/23/2016 18:35', 22],
 ['8/23/2016 17:58', 5],
 ['8/23/2016 17:01', 0],
 ['8/23/2016 16:51', 3],
 ['8/23/2016 15:01', 5],
 ['8/23/2016 14:36', 2],
 ['8/23/2016 14:23', 1],
 ['8/23/2016 13:49', 10],
 ['8/23/2016 13:48', 4],
 ['8/23/2016 13:23', 26],
 ['8/23/2016 13:13', 2],
 ['8/23/2016 12:59', 6],
 ['8/23/2016 12:43', 1],
 ['8/23/2016 12:43', 4],
 ['8/23/2016 12:35', 26],
 ['8/23/2016 12:34', 0],
 ['8/23/2016 11:50', 8],
 ['8/23/2016 8:52', 3],
 ['8/23/2016 7:29', 2],
 ['8/23/2016 4:32', 3],
 ['8/23/2016 3:50', 12],
 ['8/23/2016 1:47', 0],
 ['8/23/2016 1:17', 0],
 ['8/23/2016 0:57', 0],
 ['8/23/2016 0:53', 15],
 ['8/22/2016 22:28', 0],
 ['8/22/2016 20:56', 1],
 ['8/22/2016 19:55', 0],
 ['8/22/2016 19:28', 9],
 ['8/22/2016 18:23', 3],
 ['8/22/2016 18:01', 6],
 ['8/22/2016 17:17', 8],
 ['8/22/2016 17:05', 3],
 ['8/22/2016 17:04', 0],
 ['8/22/2016 16:56', 0],
 ['8/22/2016 16:46', 0],
 ['8/22/2016 16:41', 44],
 ['8/22/2016 15:14', 0],
 ['8/22/2016 15:06', 1],
 ['8/22/2016 14:46', 126],
 ['8/22/2016 14:45', 1],
 ['8/22/2016 14:38', 1],
 ['8/22/2016 13:52', 1],
 ...]

Calculate the amount of ask posts created in each hour of the day, along with the number of comments received.

In [24]:
import datetime as dt       # to handle the date

counts_by_hour = {}
comments_by_hour = {}

for row in results_list:
    hour_dt = dt.datetime.strptime(row[0] , "%m/%d/%Y %H:%M")
    hour = hour_dt.hour
    if hour not in counts_by_hour:
        counts_by_hour[hour] = 1
        comments_by_hour[hour] = row[1]
    else:
        counts_by_hour[hour] += 1
        comments_by_hour[hour] += row[1]
                
In [25]:
counts_by_hour 
Out[25]:
{2: 269,
 1: 282,
 22: 383,
 21: 518,
 19: 552,
 17: 587,
 15: 646,
 14: 513,
 13: 444,
 11: 312,
 10: 282,
 9: 222,
 7: 226,
 3: 271,
 23: 343,
 20: 510,
 16: 579,
 8: 257,
 0: 301,
 18: 614,
 12: 342,
 4: 243,
 6: 234,
 5: 209}
In [26]:
comments_by_hour
Out[26]:
{2: 2996,
 1: 2089,
 22: 3372,
 21: 4500,
 19: 3954,
 17: 5547,
 15: 18525,
 14: 4972,
 13: 7245,
 11: 2797,
 10: 3013,
 9: 1477,
 7: 1585,
 3: 2154,
 23: 2297,
 20: 4462,
 16: 4466,
 8: 2362,
 0: 2277,
 18: 4877,
 12: 4234,
 4: 2360,
 6: 1587,
 5: 1838}
In [27]:
# c_hour = {}
# p_hour = {}

# for row in results_list:
#     date = dt.datetime.strptime(row[0] , "%m/%d/%Y %H:%M")
#     hour = date.hour
#     if hour not in p_hour:
#         p_hour[hour] = 1
#         c_hour[hour] = 1
#     else:
#         p_hour[hour] += 1 
#         c_hour[hour] += 1
        

calculate the average comments for posts created during each hour at the day

In [ ]:
 
In [28]:
# avg number of comments for posts per hour
avg_by_hour = []

for hr in counts_by_hour:
    avg_by_hour.append([hr , comments_by_hour[hr] / counts_by_hour[hr]])
    
avg_by_hour
Out[28]:
[[2, 11.137546468401487],
 [1, 7.407801418439717],
 [22, 8.804177545691905],
 [21, 8.687258687258687],
 [19, 7.163043478260869],
 [17, 9.449744463373083],
 [15, 28.676470588235293],
 [14, 9.692007797270955],
 [13, 16.31756756756757],
 [11, 8.96474358974359],
 [10, 10.684397163120567],
 [9, 6.653153153153153],
 [7, 7.013274336283186],
 [3, 7.948339483394834],
 [23, 6.696793002915452],
 [20, 8.749019607843136],
 [16, 7.713298791018998],
 [8, 9.190661478599221],
 [0, 7.5647840531561465],
 [18, 7.94299674267101],
 [12, 12.380116959064328],
 [4, 9.7119341563786],
 [6, 6.782051282051282],
 [5, 8.794258373205741]]

Sorting and Printing Values from a List of Lists

In [29]:
# create list equal to avg_by_hour with swaped column
swaped_list = []
for row in avg_by_hour:
    swaped_list.append([row[1] , row[0]])
    
print(swaped_list)
[[11.137546468401487, 2], [7.407801418439717, 1], [8.804177545691905, 22], [8.687258687258687, 21], [7.163043478260869, 19], [9.449744463373083, 17], [28.676470588235293, 15], [9.692007797270955, 14], [16.31756756756757, 13], [8.96474358974359, 11], [10.684397163120567, 10], [6.653153153153153, 9], [7.013274336283186, 7], [7.948339483394834, 3], [6.696793002915452, 23], [8.749019607843136, 20], [7.713298791018998, 16], [9.190661478599221, 8], [7.5647840531561465, 0], [7.94299674267101, 18], [12.380116959064328, 12], [9.7119341563786, 4], [6.782051282051282, 6], [8.794258373205741, 5]]
In [30]:
# sort the swaped_list
sorted_swap = sorted(swaped_list , reverse=True)
sorted_swap
Out[30]:
[[28.676470588235293, 15],
 [16.31756756756757, 13],
 [12.380116959064328, 12],
 [11.137546468401487, 2],
 [10.684397163120567, 10],
 [9.7119341563786, 4],
 [9.692007797270955, 14],
 [9.449744463373083, 17],
 [9.190661478599221, 8],
 [8.96474358974359, 11],
 [8.804177545691905, 22],
 [8.794258373205741, 5],
 [8.749019607843136, 20],
 [8.687258687258687, 21],
 [7.948339483394834, 3],
 [7.94299674267101, 18],
 [7.713298791018998, 16],
 [7.5647840531561465, 0],
 [7.407801418439717, 1],
 [7.163043478260869, 19],
 [7.013274336283186, 7],
 [6.782051282051282, 6],
 [6.696793002915452, 23],
 [6.653153153153153, 9]]
In [31]:
print("Top 5 Hours for Ask Posts Comments")

# here iam not using the datetime.strptime method because i have converted the hours to int type at the begining
for row in sorted_swap[:6]:
    print("{}: {:.2f} average comments per post".format(row[1] , row[0]))
Top 5 Hours for Ask Posts Comments
15: 28.68 average comments per post
13: 16.32 average comments per post
12: 12.38 average comments per post
2: 11.14 average comments per post
10: 10.68 average comments per post
4: 9.71 average comments per post

from results above the the higher chance to get more comments is at 15:00 and the timezone is (Eastern Time in the US) so we can say at 3 pm est

In [32]:
print("lowest 5 hours for ask posts comments")

for avg , hr in sorted_swap[-5:]:
    hr = str(hr)
    hr = dt.datetime.strptime(hr , "%H").strftime("%H:%M")
    print("{} :  {:.2f} average comments per post".format(hr , avg) )
lowest 5 hours for ask posts comments
19:00 :  7.16 average comments per post
07:00 :  7.01 average comments per post
06:00 :  6.78 average comments per post
23:00 :  6.70 average comments per post
09:00 :  6.65 average comments per post

from the result above at 09:00 am your post for Asking HN will get least comments

Conclusion

In this project, we analyzed ask posts and show posts to determine which type of post and time receive the most comments on average. Based on our analysis, to maximize the amount of comments a post receives, we'd recommend the post be categorized as ask post and created between 15:00 and 16:00 (3:00 pm est - 4:00 pm est).

However, it should be noted that the data set we analyzed excluded posts without any comments. Given that, it's more accurate to say that of the posts that received comments, ask posts received more comments on average and ask posts created between 15:00 and 16:00 (3:00 pm est - 4:00 pm est) received the most comments on average