Guest User

Untitled

a guest
Feb 22nd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. visit_list.sort(key=operator.itemgetter('datetime'))
  2. for key, group in groupby(visit_list, key=lambda x: myfn(x['datetime'])):
  3. for a in group:
  4. print({'datetime': a['datetime'], 'value': sum(int(d['value']) for d in group)})
  5. def myfn(date):
  6. datetime_object = datetime.strptime(date, '%Y-%m-%dT%H:%M:%S')
  7. return datetime_object.hour
Add Comment
Please, Sign In to add comment