Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #85580
| Date | 2015-02-12 13:17 +0000 |
|---|---|
| From | MRAB <python@mrabarnett.plus.com> |
| Subject | Re: Group by interval time |
| References | <6f6f567d-7e25-4a74-96ef-d20cb44a9646@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.18689.1423747073.18130.python-list@python.org> (permalink) |
On 2015-02-12 12:34, charles.sartori@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.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Group by interval time charles.sartori@gmail.com - 2015-02-12 04:34 -0800
Re: Group by interval time MRAB <python@mrabarnett.plus.com> - 2015-02-12 13:17 +0000
Re: Group by interval time alister <alister.nospam.ware@ntlworld.com> - 2015-02-12 13:29 +0000
Re: Group by interval time Peter Otten <__peter__@web.de> - 2015-02-12 14:29 +0100
Re: Group by interval time charles.sartori@gmail.com - 2015-02-12 06:54 -0800
csiph-web