dayofyear is not great when going into a new year

Martin Schöön martin.schoon at gmail.com
Fri Jan 8 17:17:11 EST 2021


Den 2021-01-05 skrev Stefan Ram <ram at zedat.fu-berlin.de>:
> Martin =?UTF-8?Q?Sch=C3=B6=C3=B6n?= <martin.schoon at gmail.com> writes:
>>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.
>
> import datetime
>
> continuous_day_of_the_year = \
> ( datetime.date.today() - datetime.date( 2020, 1, 1 )).days
>
>
Thanks guys, you got me on the right track. After some further
meandering I did something close to what Stefan suggest above.
I added a column to my Pandas data frame and populated it with

content of date column - datetime(2020, 1, 1)

"regardless of what you have been told, recreational use of
mathematics is harmless"

I hope that is true for recreational programming as well :-)

/Martin


More information about the Python-list mailing list