Created
February 22, 2021 11:10
-
-
Save mjam03/b36378b296c1f0f93e8b5aec719b5f1c to your computer and use it in GitHub Desktop.
test_5
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
# handle 2014 by using np.where to merge 2 incomplete cols (change in ICD coding that year results in 2 diff cols) | |
ew_dfs[4]['All respiratory diseases (ICD-10 J00-J99)\nICD-10 v 2013 (IRIS)'] = np.where(ew_dfs[4]['All respiratory diseases (ICD-10 J00-J99)\nICD-10 v 2013 (IRIS)'] == ':', ew_dfs[4]['ICD-10 v 2010 (NCHS)'], ew_dfs[4]['All respiratory diseases (ICD-10 J00-J99)\nICD-10 v 2013 (IRIS)']) | |
ew_dfs[4] = ew_dfs[4].drop(columns=['ICD-10 v 2010 (NCHS)']) | |
# rename all cols then concat | |
for df in ew_dfs: | |
df.columns = ['Week', 'week_end', 'Deaths', 'RespiratoryDeaths', 'Year'] | |
df_ew_ed = pd.concat(ew_dfs+[df_ew_21]) | |
# add country | |
df_ew_ed['Country'] = 'England & Wales' | |
# format dates | |
df_ew_ed['week_end'] = pd.to_datetime(df_ew_ed['week_end']) | |
df_ew_ed['week_start'] = df_ew_ed['week_end'] + dt.timedelta(days=-6) | |
# format deaths | |
df_ew_ed['Deaths'] = pd.to_numeric(df_ew_ed['Deaths']) | |
df_ew_ed['RespiratoryDeaths'] = pd.to_numeric(df_ew_ed['RespiratoryDeaths']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment