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


Groups > comp.lang.python > #85580

Re: Group by interval time

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!217.188.199.168.MISMATCH!takemy.news.telefonica.de!telefonica.de!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python@mrabarnett.plus.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'skip:[ 20': 0.04; 'yet.': 0.04; '0),': 0.16; '24,': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'interval.': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'received:192.168.1.4': 0.16; 'skip:[ 30': 0.16; 'there!': 0.16; 'vars:': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'example': 0.22; 'header:User-Agent:1': 0.23; 'header:In-Reply-To:1': 0.27; 'grouping': 0.31; 'values.': 0.31; 'subject:time': 0.33; 'skip:d 20': 0.34; 'could': 0.34; 'objects': 0.35; 'two': 0.37; 'list': 0.37; 'to:addr:python-list': 0.38; '12,': 0.39; 'to:addr:python.org': 0.39; 'days': 0.60; 'email addr:gmail.com': 0.63; 'here': 0.66; 'skip:r 30': 0.69
X-CM-Score 0.00
X-CNFS-Analysis v=2.1 cv=A/HiPsmG c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=Vhvw94NMJWsA:10 a=IkcTkHD0fZMA:10 a=EBOSESyhAAAA:8 a=pGLkceISAAAA:8 a=EN1oexMKevY2K_mYtCkA:9 a=-VQNqaJfEAReKZCT:21 a=OCIlZx_NNdTQHuZR:21 a=QEXdDO2ut3YA:10
X-AUTH mrabarnett@:2500
Date Thu, 12 Feb 2015 13:17:42 +0000
From MRAB <python@mrabarnett.plus.com>
User-Agent Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0
MIME-Version 1.0
To python-list@python.org
Subject Re: Group by interval time
References <6f6f567d-7e25-4a74-96ef-d20cb44a9646@googlegroups.com>
In-Reply-To <6f6f567d-7e25-4a74-96ef-d20cb44a9646@googlegroups.com>
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.18689.1423747073.18130.python-list@python.org> (permalink)
Lines 22
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1423747073 news.xs4all.nl 2832 [2001:888:2000:d::a6]:41533
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:85580

Show key headers only | View raw


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 | 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