Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #85581

Re: Group by interval time

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 <alister.nospam.ware@ntlworld.com>
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 <mbi9rt$o7c$1@speranza.aioe.org> (permalink)
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

Show key headers only | View raw


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.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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