dayofyear is not great when going into a new year

dn PythonList at danceswithmice.info
Tue Jan 5 17:12:11 EST 2021


On 1/6/21 9:55 AM, Martin Schöön wrote:
> Hello,
> 
> I have had some Python fun with COVID-19 data. I have done
> some curve fitting and to make that easier I have transformed
> date to day of year. Come end of 2020 and beginning of 2021
> and this idea falls on its face.
> 
> There must be a better way of doing this.
> 
> I am using Pandas for reading and manipulating data coming
> from a csv file. Scipy, numpy and matplotlib are used
> for the curve fitting and plotting.


An important question is how the day/date is presented in these graphs.

The Julian date format used to be more common in Data Processing. Dates
are expressed as yy-ddd. Thus, prepending "20" or "21" to existing
day-of-year numbers, would separate and sequence correctly.
(NB carefully consider str cf int)

Another solution is to use a Unix Timestamp for each day.

In both cases, arithmetic comparison-logic is possible, and library
routines exist to format various reporting-formats.
-- 
Regards =dn


More information about the Python-list mailing list