Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python weekly aggreation string time

from collections import defaultdict
from datetime import datetime as dt
curr = '2019-01-01'
idx = 0
dic = defaultdict(list)
for i in ts:
 if ( dt.strptime(i, '%Y-%m-%d') -  dt.strptime(curr, '%Y-%m-%d')).days < 7 :
     dic[idx].append(i)
 else:
    curr = i
    idx += 1
    dic[idx].append(i)
print(dic.values())
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #weekly #aggreation #string #time
ADD COMMENT
Topic
Name
3+6 =