-
Notifications
You must be signed in to change notification settings - Fork 1
/
change_in_behavior.py
128 lines (84 loc) · 3.06 KB
/
change_in_behavior.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/usr/bin/env python
# coding: utf-8
# In[52]:
import numpy as np
import datetime
import operator
import csv
i=0
from collections import defaultdict
d = defaultdict(list)
# d={'1':[1, 2, 3]}
# d['1'].append(4)
# print(d['1'][3])
with open('/home/ajit/Desktop/phone_messages.csv', 'r') as readfile:
filereader=csv.reader(readfile)
dt1='2018-07-01'#deciding range of the time period of december:=
year,month,day = (int(x) for x in dt1.split('-'))
ansjl1 = datetime.date(year, month, day)
dt2='2019-08-01'
year,month,day = (int(x) for x in dt2.split('-'))
ansAg1 = datetime.date(year, month, day)
dt1='2018-09-1'#deciding range of the time period of december:=
year,month,day = (int(x) for x in dt1.split('-'))
ansSe1 = datetime.date(year, month, day)
dt2='2018-10-1'
year,month,day = (int(x) for x in dt2.split('-'))
ansOc1 = datetime.date(year, month, day)
dt1='2018-11-1'#deciding range of the time period of december:=
year,month,day = (int(x) for x in dt1.split('-'))
ansNo1 = datetime.date(year, month, day)
dt2='2018-12-1'
year,month,day = (int(x) for x in dt2.split('-'))
ansDe1 = datetime.date(year, month, day)
for row in filereader:
if(i>=0):
when=row[7]
x=when.split(" ")
dt=x[1]
date=x[0]
year,month,day = (int(x) for x in date.split('-'))
ans = datetime.date(year, month, day)
if row[1] in d and row[3]=='1':
if ansjl1<=ans and ans<ansAg1:
d[row[1]][0]=1+d[row[1]][0]
if ansAg1<=ans and ans<ansSe1:
d[row[1]][1]=1+d[row[1]][0]
if ansSe1<=ans and ans<ansOc1:
d[row[1]][2]=1+d[row[1]][0]
if ansOc1<=ans and ans<ansNo1:
d[row[1]][3]=1+d[row[1]][0]
if ansNo1<=ans and ans<ansDe1:
d[row[1]][4]=1+d[row[1]][0]
elif row[3]=='1':
d[row[1]].append(0)
d[row[1]].append(0)
d[row[1]].append(0)
d[row[1]].append(0)
d[row[1]].append(0)
d[row[1]].append(0)
if ansjl1<=ans and ans<ansAg1:
d[row[1]][0]=1
if ansAg1<=ans and ans<ansSe1:
d[row[1]][1]=1
if ansSe1<=ans and ans<ansOc1:
d[row[1]][2]=1
if ansOc1<=ans and ans<ansNo1:
d[row[1]][3]=1
if ansNo1<=ans and ans<ansDe1:
d[row[1]][4]=1
data=d
x=data.keys()
array=[]
for z in x:
array.append(z)
array.append(d[z][0])
print(array)
# In[48]:
from collections import defaultdict
d = defaultdict(list)
d={'2018'}
print(d)
# In[ ]:
# In[18]:
# In[ ]: