Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- visit_list.sort(key=operator.itemgetter('datetime'))
- for key, group in groupby(visit_list, key=lambda x: myfn(x['datetime'])):
- for a in group:
- print({'datetime': a['datetime'], 'value': sum(int(d['value']) for d in group)})
- def myfn(date):
- datetime_object = datetime.strptime(date, '%Y-%m-%dT%H:%M:%S')
- return datetime_object.hour
Add Comment
Please, Sign In to add comment