Skip to content

Instantly share code, notes, and snippets.

@mashhadazam
Last active March 6, 2020 14:52
Show Gist options
  • Save mashhadazam/36f5e9e809799998fb86ffc461e199dd to your computer and use it in GitHub Desktop.
Save mashhadazam/36f5e9e809799998fb86ffc461e199dd to your computer and use it in GitHub Desktop.
### Melt the dateframe into the right shape and set index
def cleandata(df_raw):
df_cleaned=df_raw.melt(id_vars=['Province/State','Country/Region','Lat','Long'],value_name='Cases',var_name='Date')
df_cleaned=df_cleaned.set_index(['Country/Region','Province/State','Date'])
return df_cleaned
# Clean all datasets
ConfirmedCases=cleandata(ConfirmedCases_raw)
Deaths=cleandata(Deaths_raw)
Recoveries=cleandata(Recoveries_raw)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment