Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.etla.org!aioe.org!.POSTED!not-for-mail From: alister Newsgroups: comp.lang.python Subject: Re: Group by interval time Date: Thu, 12 Feb 2015 13:29:34 +0000 (UTC) Organization: Aioe.org NNTP Server Lines: 32 Message-ID: References: <6f6f567d-7e25-4a74-96ef-d20cb44a9646@googlegroups.com> NNTP-Posting-Host: i/OG3EjHvs04xHrpB0XnAg.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2) X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.python:85581 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.