Created
March 7, 2020 18:32
-
-
Save Arkoniak/a5c2cd23be353c54938fecf7317518bd to your computer and use it in GitHub Desktop.
Covid-19 julia reshape
This file contains hidden or 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
using HTTP, DataFrames, CSV | |
confirmed_url = "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Confirmed.csv" | |
deaths_url = "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Deaths.csv" | |
recovered_url = "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Recovered.csv" | |
confirmed_df = CSV.File(IOBuffer(HTTP.get(confirmed_url).body)) |> DataFrame | |
deaths_df = CSV.File(IOBuffer(HTTP.get(deaths_url).body)) |> DataFrame | |
recovered_df = CSV.File(IOBuffer(HTTP.get(recovered_url).body)) |> DataFrame | |
ncols = size(confirmed_df, 2) | |
confirmed_df = DataFrames.stack(confirmed_df, 5:ncols) | |
deaths_df = DataFrames.stack(deaths_df, 5:ncols) | |
recovered_df = DataFrames.stack(recovered_df, 5:ncols) | |
j1 = join(confirmed_df, deaths_df, on = [Symbol("Province/State"), Symbol("Country/Region"), :Lat, :Long, :variable], makeunique=true) | |
j2 = join(j1, recovered_df, on = [Symbol("Province/State"), Symbol("Country/Region"), :Lat, :Long, :variable], makeunique=true) | |
j2[!, :result] = j2[!, :value] .- j2[!, :value_1] .- j2[!, :value_2] | |
println(first(j2, 6)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment