Created
February 22, 2021 11:10
-
-
Save mjam03/3d4d6fbb01acc251e8efdad7c71f1108 to your computer and use it in GitHub Desktop.
test_11
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
# grab 2020 and 2021 excel tables, extract, reformat and concat | |
# 2020 | |
df_s_m_20 = pd.read_csv(zips.extract(scot_20_m_fd), header=2)[:4].T[2:][[0,3]] | |
df_s_m_20 = df_s_m_20.dropna() | |
df_s_m_20.columns = ['week_start', 'Deaths'] | |
df_s_m_20['Week'] = df_s_m_20.index | |
df_s_m_20['Year'] = 2020 | |
# 2021 | |
df_s_m_21 = pd.read_csv(zips.extract(scot_21_m_fd), header=2)[:4].T[2:][[0,3]] | |
df_s_m_21 = df_s_m_21.dropna() | |
df_s_m_21.columns = ['week_start', 'Deaths'] | |
df_s_m_21['Week'] = df_s_m_21.index | |
df_s_m_21['Year'] = 2021 | |
# concat, add country and cause | |
df_s_m = pd.concat([df_s_m_20, df_s_m_21]) | |
df_s_m['Cause'] = 'COVID Mention' | |
df_s_m['Country'] = 'Scotland' | |
df_s_m = df_s_m[['Country', 'Year', 'Week', 'week_start', 'Cause', 'Deaths']] | |
df_s_m['Week'] = pd.to_numeric(df_s_m['Week']) | |
df_s_m.tail() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment