analyzing time

Neil Cerutti neilc at norwich.edu
Fri Jul 5 21:35:33 CEST 2013


On 2013-07-05, noydb <jenn.duerr at gmail.com> wrote:
> Hello All,
>
> I have a table with a column of type date, with dates and time
> 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?
>
> 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?
>
> Python 2.7, Windows 7.
>
> Any guidance would be greatly appreciated!  Time seems tricky...

Time *is* really tricky, but that's because we humans created a
tricky system. If can ignore issues of timespampts, timezones and
daylight savings time, then time handling in Python can be
simple.

datetime.datetime.strptime can translate the time format above
into datetime.datetime objects, which provide all the methods you
will need.

To find clusters and min and max values you will likely need to
put the datetime objects in a list, and use some Python builtins
and list methods.

-- 
Neil Cerutti



More information about the Python-list mailing list