import matplotlib as mpl
import matplotlib.pyplot as plt
plt.ioff()
-# # %matplotlib inline
+# %matplotlib inline
# %%
# %%
DEATH_COUNT_THRESHOLD = 10
-COUNTRIES_CORE = tuple(sorted('IT DE UK ES IE FR BE'.split()))
-COUNTRIES_NORDIC = tuple('SE NO DK FI UK'.split())
-COUNTRIES_FRIENDS = tuple('IT UK ES BE SI MX'.split())
+COUNTRIES_CORE = tuple(sorted('ITA DEU GBR ESP IRL FRA BEL'.split()))
+# COUNTRIES_NORDIC = tuple('SE NO DK FI UK'.split())
+COUNTRIES_FRIENDS = tuple('ITA GBR ESP BEL SVN MEX'.split())
# COUNTRIES_FRIENDS = 'IT UK ES BE SI PT'.split()
-COUNTRIES_AMERICAS = ('AG', 'AR', 'AW', 'BS', 'BB', 'BZ', 'BM', 'BO', 'BR', 'VG', 'KY', # excluding Canada and USA
- 'CL', 'CO', 'CR', 'CU', 'CW', 'DM', 'DO', 'EC', 'SV', 'GL', 'GD', 'GT',
- 'GY', 'HT', 'HN', 'JM', 'MX', 'MS', 'NI', 'PA', 'PY', 'PE', 'PR', 'KN',
- 'LC', 'VC', 'SX', 'SR', 'TT', 'TC', 'VI', 'UY', 'VE')
-COUNTRIES_OF_INTEREST = tuple(set(COUNTRIES_CORE + COUNTRIES_FRIENDS))
-COUNTRIES_ALL = tuple(set(COUNTRIES_CORE + COUNTRIES_FRIENDS + COUNTRIES_NORDIC + COUNTRIES_AMERICAS))
+# COUNTRIES_AMERICAS = ('AG', 'AR', 'AW', 'BS', 'BB', 'BZ', 'BM', 'BO', 'BR', 'VG', 'KY', # excluding Canada and USA
+# 'CL', 'CO', 'CR', 'CU', 'CW', 'DM', 'DO', 'EC', 'SV', 'GL', 'GD', 'GT',
+# 'GY', 'HT', 'HN', 'JM', 'MX', 'MS', 'NI', 'PA', 'PY', 'PE', 'PR', 'KN',
+# 'LC', 'VC', 'SX', 'SR', 'TT', 'TC', 'VI', 'UY', 'VE')
+# COUNTRIES_OF_INTEREST = tuple(set(COUNTRIES_CORE + COUNTRIES_FRIENDS))
+# COUNTRIES_ALL = tuple(set(COUNTRIES_CORE + COUNTRIES_FRIENDS + COUNTRIES_NORDIC + COUNTRIES_AMERICAS))
# %%
-query_string = f'''select report_date, geo_id, deaths_weekly, culm_deaths
+query_string = f'''select date, country_code, deaths_weekly, culm_deaths
from weekly_cases
-where geo_id in {COUNTRIES_CORE}
-order by report_date, geo_id'''
+where country_code in {COUNTRIES_CORE}
+order by date, country_code'''
country_data = pd.read_sql_query(query_string,
engine,
- index_col = 'report_date',
- parse_dates = ['report_date']
+ index_col = 'date',
+ parse_dates = ['date']
)
# %%
-deaths_culm = country_data.pivot(columns='geo_id', values='culm_deaths')
+deaths_culm = country_data.pivot(columns='country_code', values='culm_deaths')
+# %%
+# country_data
+
+# %%
+# deaths_culm
+
# %%
ax = deaths_culm.loc['2020-03-15':].plot(figsize=(10, 6), title="Total deaths, linear")
ax.set_xlabel(f"Date")
# %%
-deaths_weekly = country_data.pivot(columns='geo_id', values='deaths_weekly')
+deaths_weekly = country_data.pivot(columns='country_code', values='deaths_weekly')
# %%
# %%
-ax = deaths_weekly.iloc[-6:].plot(figsize=(10, 6), title="Deaths per week")#, ylim=(-10, 100))
+ax = deaths_weekly.iloc[-6:].plot(figsize=(10, 6), title="Deaths per week, last 6 weeks")#, ylim=(-10, 100))
ax.set_xlabel("Date")
text_x_pos = deaths_weekly.last_valid_index() + pd.Timedelta(days=0.5)