Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'column': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'second.': 0.09; 'statistical': 0.09; 'way:': 0.09; 'python': 0.11; 'jan': 0.12; 'windows': 0.15; 'appreciated!': 0.16; 'ignoring': 0.16; 'pairs': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'wrote:': 0.18; 'seems': 0.21; 'header:User-Agent:1': 0.23; 'entries': 0.24; 'looks': 0.24; '(or': 0.24; 'sort': 0.25; 'header:X-Complaints- To:1': 0.27; 'header:In-Reply-To:1': 0.27; '(like': 0.30; 'subject:time': 0.33; 'table': 0.34; 'there': 0.35; 'date.': 0.36; 'dates': 0.36; 'entry': 0.36; 'whatever': 0.38; 'to:addr:python- list': 0.38; 'pm,': 0.38; 'guidance': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'days': 0.60; 'received:173': 0.61; 'first': 0.61; 'yes': 0.68; 'date,': 0.68; 'records': 0.73; 'day': 0.76; '11am': 0.84; 'column.': 0.84; 'received:fios.verizon.net': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: analyzing time Date: Fri, 05 Jul 2013 15:54:46 -0400 References: <2aa041fe-8226-4fb9-9ce6-b1eb48a19e4d@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-173-75-251-66.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 In-Reply-To: <2aa041fe-8226-4fb9-9ce6-b1eb48a19e4d@googlegroups.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 39 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1373054103 news.xs4all.nl 15869 [2001:888:2000:d::a6]:53208 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:50015 On 7/5/2013 3:18 PM, noydb wrote: > I have a table with a column of type date, with dates and time This is a datetime in Python parlance. > combined (like '1/6/2013 3:52:69PM'), that spans many months. How > would I pull out records that are the first and last entries per > day? Sort on that column. Look at pairs of rows. If the days differ, you have the last of the first and the first of the second. One way: it = dt1 = next(it) d1 = date(dt1) # whatever that looks like for row in it: dt2 = row d2 = date(dt2) if d1 != d2: do_whatever(dt1, dt2) dt1, d1 = dt2, d2 > Also, if I wanted to find time clusters per day (or per week) -- like > if an entry is made every day around 11am -- is there a way to get at > that temporal statistical cluster? Make a histogram of time, ignoring date. > Python 2.7, Windows 7. > > Any guidance would be greatly appreciated! Time seems tricky... Yes -- Terry Jan Reedy