Given a list containing monthly numerical data, how can I easily convert this into quarterly data?
x= [5,8,3,4,5,6,1,2,5,3,11,8] #monthly data for Jan-Dec
Desired output:
[5+8+3, 4+5+6, 1+2+5, 3+11+8] #converted to quarterly data
I wanted to do something like [a+b+c for a,b,c in x]
but x it says x is not iterable.
I don't think this is a duplicate. I am specifically looking for a list comprehension solution.