-
Notifications
You must be signed in to change notification settings - Fork 0
/
timeAnalysis.py
71 lines (41 loc) · 995 Bytes
/
timeAnalysis.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
file = pd.read_csv("saraAlaa.csv")
time = file['created_at']
tim = []
for i in range(len(time)):
tim.append(time[i].split(' '))
fintim = []
for i in range(len(tim)):
fintim.append(tim[i][1][0])
fintim[i] += tim[i][1][1]
fintim[i] = int(fintim[i])
xAxis = []
for i in range(25):
xAxis.append(i)
def occ(arr,n):
count = 0
for i in range(len(arr)):
if(arr[i] == n and arr[i] != -1):
count+= 1
arr[i] = -1
return n,count
def arrcount(arr):
fin = []
for i in range(len(arr)):
fin.append(occ(arr,arr[i]))
return fin
tup = arrcount(fintim)
out_tup = [i for i in tup if i[0] >= 0]
x = []
y =[]
for i in range(len(out_tup)):
x.append(out_tup[i][0])
y.append(out_tup[i][1])
plt.bar(x,y, 0.5, color="red")
plt.xticks(np.arange(min(x), max(x)+1, 1.0))
plt.title('Sara Twitter Activity')
plt.ylabel("Number of tweets posted")
plt.xlabel("Time in 24 hrs format")
plt.show()