On 2015-02-12 12:34, charles.sart...@gmail.com 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.
Try grouping by the number of days since datetime.datetime(2013, 1, 1,
0, 0), integer-divided by 12.
--
https://mail.python.org/mailman/listinfo/python-list