-
Notifications
You must be signed in to change notification settings - Fork 67
/
latam_covid.py
27 lines (22 loc) · 913 Bytes
/
latam_covid.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
import pandas as pd
import matplotlib.pyplot as plt
import datetime as dt
plt.style.use('dark_background')
fig, ax = plt.subplots(figsize=(12,10))
data = pd.read_excel('https://covid.ourworldindata.org/data/owid-covid-data.xlsx')
countries = ['ARG','BRA','PER','CHL','COL','MEX']
for country in countries:
p = (data.loc[data.iso_code == country]).copy()
p.set_index('date',inplace=True)
p.index = pd.to_datetime(p.index)
p.sort_index(inplace=True)
p['pct_change'] = p.total_cases.pct_change().rolling(30).mean() *100
if country=='ARG':
width=5
else:
width=1
ax.plot(p['pct_change'], lw=width, label=country)
ax.legend(fontsize=14, loc='upper right')
ax.set_xlim(dt.datetime(2020,5,1),dt.datetime.now())
ax.set_ylim(3,10)
plt.suptitle('Tasa de crecimiento de casos. Media movil 30 dias. Incremento % diario', y=0.93)