Last active
March 1, 2021 05:04
-
-
Save sergeyf/0c6593756889a73462c9f6c0c7bbd755 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
Created on Tue Jul 21 07:44:21 2020 | |
@author: serge | |
""" | |
import matplotlib.pyplot as plt | |
import pandas as pd | |
import seaborn as sns | |
sns.set(context='talk') | |
date = 'feb-17' | |
######### | |
#url = f'https://www.kingcounty.gov/depts/health/covid-19/data/~/media/depts/health/communicable-diseases/documents/C19/data/daily-counts-and-rate-{date}.ashx' | |
url = f'https://www.kingcounty.gov/depts/health/covid-19/data/~/media/depts/health/communicable-diseases/documents/C19/data/total-counts-by-date-city-{date}.ashx' | |
df1 = pd.read_excel(url, 'Positives') | |
flag = (df1['Result_Date'] >= '2020-03-01') & (df1['City'] == 'Seattle') | |
df1 = df1[flag] | |
df2 = pd.read_excel(url, 'Hospitalizations')[flag] | |
df3 = pd.read_excel(url, 'Deaths')[flag] | |
df1.plot(x='Result_Date', y='Positive_Rate', figsize=(20, 8), title='Seattle Daily Positive Rate') | |
ax = df2.plot(x='Admission_Date', y='HospitalizationRate', figsize=(20, 8)) | |
df3.plot(ax=ax, x='Death_Date', y='Death_Rate', title='Seattle Daily Hospitalization and Death Rates') | |
######### | |
url = f'https://www.kingcounty.gov/depts/health/covid-19/data/~/media/depts/health/communicable-diseases/documents/C19/data/biweekly-counts-rates-by-geography-{date}.ashx' | |
df = pd.read_excel(url, 'ZIP') | |
df = df[df['ZIP'] == 98115] | |
df.plot(x='Week_End', y='Positive_Rate', figsize=(20, 8), title='98115 Biweekly Counts') | |
ax = df.plot(x='Week_End', y='Hospitalizations', figsize=(20, 8)) | |
df.plot(ax=ax, x='Week_End', y='Deaths', title='98115 biweekly data') | |
######### | |
url = f'https://www.kingcounty.gov/depts/health/covid-19/data/~/media/depts/health/communicable-diseases/documents/C19/data/weekly-counts-by-date-all-demographics-{date}.ashx' | |
df = pd.read_excel(url, 'Age Group') | |
df['Week_Start'] = df['Week'].apply(lambda s: s.split(' - ')[0]) | |
df['Week_Start'] = pd.to_datetime(df['Week_Start']) | |
df['Week_End'] = df['Week'].apply(lambda s: s.split(' - ')[1]) | |
df['Week_End'] = pd.to_datetime(df['Week_End']) | |
fig, ax = plt.subplots(figsize=(20, 8)) | |
for label, df_sub in df.groupby('Age_Group'): | |
df_sub.plot(x='Week_End', y='Positives', ax=ax, label=label) | |
plt.legend() | |
plt.title('King County Weekly Positive Counts') | |
plt.show() | |
fig, ax = plt.subplots(figsize=(20, 8)) | |
for label, df_sub in df.groupby('Age_Group'): | |
df_sub.plot(x='Week_End', y='Hospitalizations', ax=ax, label=label) | |
plt.legend() | |
plt.title('King County Weekly Hospitalizations Counts') | |
plt.show() | |
fig, ax = plt.subplots(figsize=(20, 8)) | |
for label, df_sub in df.groupby('Age_Group'): | |
df_sub.plot(x='Week_End', y='Deaths', ax=ax, label=label) | |
plt.legend() | |
plt.title('King County Weekly Deaths Counts') | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment