-
Notifications
You must be signed in to change notification settings - Fork 0
/
covidplot.py
30 lines (28 loc) · 910 Bytes
/
covidplot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import pandas as pd
from datetime import datetime
def dateNow():
now = datetime.now()
month=now.month
if (month<10):
month='0'+str(month)
else:
month=str(month)
d=str(now.year)+"-"+month+"-"+str(now.day)
return d
class CovidData:
def __init__(self, country='Chile',adress='https://covid.ourworldindata.org/data/owid-covid-data.csv'):
self.adress=adress
self.country=country
self.reset()
def reset(self):
data = pd.read_csv(self.adress)
data_country = data[data['location']==self.country]
self.data_country_indexed = data_country.set_index('date')
def plot(self,param):
print(param+" in "+self.country+" since 2020-01-01 until "+dateNow())
if(param=="vacunas"):
param='new_vaccinations_smoothed'
if(param=="casos"):
param='new_cases_smoothed'
subdata=self.data_country_indexed.loc["2020-01-01":dateNow(), param]
subdata.plot()