Group by interval time
charles.sartori at gmail.com
charles.sartori at gmail.com
Thu Feb 12 07:34:03 EST 2015
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.
More information about the Python-list
mailing list