Skip to content

Instantly share code, notes, and snippets.

@mjam03
Created February 22, 2021 11:10
Show Gist options
  • Save mjam03/82b27a93559908b9384f0c98a29f2db8 to your computer and use it in GitHub Desktop.
Save mjam03/82b27a93559908b9384f0c98a29f2db8 to your computer and use it in GitHub Desktop.
test_13
cods = [x for x in df_s_cod if x!='Week' and x!='Year' and x!='Country' and x!='week_start']
df_s_cod = pd.melt(df_s_cod, id_vars=['Country', 'Year', 'Week', 'week_start'], value_vars=cods, var_name='Cause', value_name='Deaths')
df_s_cod = pd.concat([df_s_cod, df_s_m])
df_s_cod['Deaths'] = pd.to_numeric(df_s_cod['Deaths'].apply(lambda x: x.replace('-', '').replace(',', '').strip()))
df_s_cod['week_start'] = pd.to_datetime(df_s_cod['week_start'])
# homogenise week_start / week_end with ONS
df_s_cod = pd.merge(left=df_s_cod.drop(columns=['week_start']), right=df_week_map, how='left', on=['Year', 'Week'])
df_s_cod.tail()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment