alvarobartt / covid-daily

🦠 COVID-19 Daily Data from Worldometers with Python
https://covid_daily.readthedocs.io
MIT License
13 stars 6 forks source link

Y2021 bug ? Seems we are still in 2020 ? #4

Closed kokopopse closed 3 years ago

kokopopse commented 3 years ago

Code data = covid_daily.data(country='france', chart='graph-deaths-daily', as_json=False) print(data.tail())

Result Novel Coronavirus Daily Deaths Date
2020-12-29 468.0 2020-12-30 303.0 2020-12-31 251.0 2020-01-01 133.0 2020-01-02 156.0

RafaelMendozaArriaga commented 3 years ago

Are there any updates with this bug?

The dates could be overwritten externally, but I am interested to know what will happen on Feb 15 when the dates may repeat if the bug is not fixed.

Thank you

Rafa

kokopopse commented 3 years ago

For my own needs I fixed the bug with this patch in file covid.py Not very pythonic but it works. Maybe someone can propose better code.

12c12 < from datetime import datetime

from datetime import datetime, timedelta 160a161,164

    # Make dates increasing forever
    for date_index in range(1,len(y)):
        while y[date_index]<=y[date_index-1]: y[date_index] += timedelta(days=1) 
RafaelMendozaArriaga commented 3 years ago

Thanks,

I used something similar, but there might be something better than this.

df.index=pd.date_range(df.index[0],df.index[0]+timedelta(len(df)-1)) ?

alvarobartt commented 3 years ago

Thank you both @kokopopse and @RafaelMendozaArriaga for reporting this issue!

OK let me recap on this the next week as I'll have more free time to spend on this Python package 🤗

kokopopse commented 3 years ago

----- Le 12 Jan 21, à 22:31, RafaelMendozaArriaga notifications@github.com a écrit :

| Thanks,

| I used something similar, but there might be something better than this.

| df.index=pd.date_range(df.index[0],df.index[0]+timedelta(len(df)-1)) ?

| — | You are receiving this because you authored the thread. | Reply to this email directly, [ | https://github.com/alvarobartt/covid-daily/issues/4#issuecomment-759028179 | | view it on GitHub ] , or [ | https://github.com/notifications/unsubscribe-auth/ABGSXTTCGHJNG7OKS3RTC5DSZS5SPANCNFSM4VRXV5UA | | unsubscribe ] .

Yes, more pythonic, and in the spirit of the pandas dataframes.

Thanks to all --


Jean-Paul Marmorat

akhilarj commented 3 years ago

Any updates/solutions to this bug? I have the same issue now.

alvarobartt commented 3 years ago

Hi @kokopopse, @RafaelMendozaArriaga and @akhilarj! 🔥

This has already been fixed as you said in a more Pythonic way 🤗 Feel free to download the latest version of covid_daily, which is the 1.2 release available at https://pypi.org/project/covid-daily/. The installation command is as it follows:

pip install covid_daily==1.2

Remember to follow me on GitHub and on Twitter so as to get notified of all the projects and updates! 👍🏻