Mapping a series of Dates to an array of Numbers
cwitts at gmail.com
Tue Jun 17 14:50:58 CEST 2008
On Jun 17, 2:15 pm, J-Burns <arslanbur... at gmail.com> wrote:
> Hello. Got a problem here.
> Ive got a set of points tht id be plotting. Those points would contain
> the date on which the work was done against its frequency. Supposedly
> if i did something on the 28th of March one of the points would be
> (28, respective freq). The next time i did my work on the 1st of
> April. So my next point would (1,freq).
> Now how could i map all the dates to another array so that when im
> plotting them i can plot the points as (day 1, freq), (day2,freq),
> (day4 , freq) and so on rather than having points like (28, freq),
> (29,freq), (1,freq) and blah blah blah.
> Id be needing some help on how to use the time class in python as
> well. Thnx
For every day you could build a timestamp and frequency pair, hell,
you don't even need to use the time module if you're capturing data
manually. If you build your dataset as "(timestamp, frequency)" and
if frequency is nothing then use "None" when you extract data to plot
you could use a simple list comprehension to retrieve days that
actually had items "[(timestamp,frequency) for timestamp,frequency in
data_structure where frequency != None]". Now you have your own list
that is composed just of data pairs where there is a frequency.
More information about the Python-list