Mapping a series of Dates to an array of Numbers

J

J-Burns

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
 
J

J-Burns

Btw dnt forget the solution should also cater to this problem:
Supposedly there is a day on which i did not do anything. Than that
particular spot in my graph should be left empty. Meaning that if i
did something on the 1st March and after it i did something on the 7th
March. Then essentially 1st march should be mapped to day1 and 7th
march to day 7(not day2)... :p
 
C

Chris

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top