Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #This function creates a monthly average from list with
- #such structure (["%Y-%m-%d %H:%M:%S", float],["%Y-%m-%d %H:%M:%S", float]..)
- def monthlyAverage(array):
- tmpMonthArray=[[]*12 for x in xrange(12)]
- resultArray=[]
- for eachPair in array:
- #print eachPair[0]
- dateObjekts=datetime.datetime.strptime(eachPair[0],"%Y-%m-%d %H:%M:%S")
- menesis=dateObjekts.month
- tmpMonthArray[menesis-1].append(eachPair[1])
- i=1
- for each in tmpMonthArray:
- resultArray.append([i,sum(each)/len(each)])
- i+=1
- print resultArray
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement