Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import datetime
- promedio = [[datetime.datetime(2013, 4, 10, 12, 0), 23.4],[datetime.datetime(2013, 4, 10, 12, 0), 25.81], [datetime.datetime(2013, 4, 10, 12, 0), 25.08],
- [datetime.datetime(2013, 4, 10, 13, 0), 18.49], [datetime.datetime(2013, 4, 10, 14, 0), 20.74], [datetime.datetime(2013, 4, 10, 14, 0), 25.86] ]
- ultima_fecha=None
- group = []
- res = []
- suma=0
- cantidad=0
- for d, v in promedio:
- if not ultima_fecha is None and ultima_fecha != d:
- res.append((ultima_fecha, suma/cantidad))
- suma=0
- cantidad=0
- ultima_fecha=d
- suma+= v
- cantidad+=1
- if cantidad>0:
- res.append((ultima_fecha, suma/cantidad))
- print res
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement