Group by interval time

alister alister.nospam.ware at ntlworld.com
Thu Feb 12 08:29:34 EST 2015


On Thu, 12 Feb 2015 04:34:03 -0800, charles.sartori wrote:

> Hello there!
> 
> I`m trying to group by a list of Row() objects in 12days interval and
> sum(). values. Here is an example of the list
> 
> [Row(time=datetime.datetime(2013, 1, 1, 0, 0), sum=4676557380615),
> Row(time=datetime.datetime(2013, 1, 2, 0, 0), sum=6549630855895),
> Row(time=datetime.datetime(2013, 1, 3, 0, 0), sum=6549630855895), ...]
> 
> Row() objects has two vars: row.time and row.sum
> 
> 
> The result that I`m looking for is:
> [[datetime.datetime(2013, 1, 1, 0, 0), value],
> [datetime.datetime(2013, 1, 12, 0, 0), value],
> [datetime.datetime(2013, 1, 24, 0, 0), value]
> ]
> Where value is the sum() of all row.sum in that interval.
> 
> I`m trying to use itertools.groupby by I could not get it to work yet.
> 
> Thnak you.

what is the code you have tried & what errors are you getting?



-- 
life, n.:
	A whim of several billion cells to be you for a while.



More information about the Python-list mailing list