Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #50015
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Subject | Re: analyzing time |
| Date | 2013-07-05 15:54 -0400 |
| References | <2aa041fe-8226-4fb9-9ce6-b1eb48a19e4d@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4308.1373054103.3114.python-list@python.org> (permalink) |
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 = <table iterator>
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
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
analyzing time noydb <jenn.duerr@gmail.com> - 2013-07-05 12:18 -0700 Re: analyzing time Neil Cerutti <neilc@norwich.edu> - 2013-07-05 19:35 +0000 Re: analyzing time Skip Montanaro <skip@pobox.com> - 2013-07-05 14:43 -0500 Re: analyzing time Gary Herron <gherron@digipen.edu> - 2013-07-05 12:47 -0700 Re: analyzing time Terry Reedy <tjreedy@udel.edu> - 2013-07-05 15:54 -0400
csiph-web