Given that some people with COVID-19 had no symptoms or mild symptoms, the reported number of cases was never completely accurate. Now with widespread home testing, the reported cases are even less accurate.
Likely, COVID-19 is now or close to being endemic rather than a pandemic. Whatever term we use, COVID-19 is here to stay like the flu.
Updated Nov 27, 2022
The US data comes from https://usafacts.org which was started by Steve Ballmer, the former CEO of Microsoft.
Roger Whitney
whitney@sdsu.edu
http://www.eli.sdsu.edu
Plot the number of new cases per week in the country. Going back up but no one cares.
plot_country(county_new_weekly_covid)
Steep up and steep down.
plot_county("CA", "San Diego County ", county_new_weekly_covid)
plot_county("CA", "Orange County ", county_new_weekly_covid)
plot_county("CA", "Los Angeles County ", county_new_weekly_covid)
plot_state("CA", states_new_weekly_covid)
plot_two_states("MN", "IL", states_new_weekly_covid)
plot_two_states("AL", "FL", states_new_weekly_covid)
plot_two_states("GA", "WI", states_new_weekly_covid)
plot_two_states("SD", "ND", states_new_weekly_covid)
plot_two_states("VA", "MD", states_new_weekly_covid)
plot_two_states("NY", "WA", states_new_weekly_covid)
plot_two_states("AZ", "TX", states_new_weekly_covid)
plot_two_states("UT", "NV", states_new_weekly_covid)
This was created using Jupyter notebook run Julia 1.8.1. The following is the Julia code used.
using DataFrames
using DataFramesMeta
using CSV
using StatsPlots
using Lazy
using Dates
#using Downloads
function issunday(datestring)
date_format = DateFormat("y-m-d")
date = Date(datestring, date_format)
Dates.dayofweek(date) == 7
end
"""
First 4 columns are state & county ids
"""
usa_covid_just_data(raw_covid_data) = raw_covid_data[:,5:end]
usa_covid_labels(raw_covid_data) = raw_covid_data[:,1:4]
function usa_covid_sunday_cumulative(raw_covid_data)
sundays = filter(issunday, names(raw_covid_data))
return raw_covid_data[:, sundays]
end
"""Returns new cases each week"""
function counties_covid_weekly(raw_covid_data)
labels = usa_covid_labels(raw_covid_data)
just_data = usa_covid_just_data(raw_covid_data)
sunday_cumulative = usa_covid_sunday_cumulative(just_data)
sundays = names(sunday_cumulative[:,2:end])
weekly_new_cases = sunday_cumulative[:,2:end] .- rename(sunday_cumulative[:,1:end-1], sundays)
with_labels = hcat(labels, weekly_new_cases)
return rename!(with_labels, [2 => :County] )
end
function state_covid_weekly_cummulative(raw_covid_data)
# Is this needed?
labels = usa_covid_labels(raw_covid_data)
just_data = usa_covid_just_data(raw_covid_data)
sunday_cumulative = usa_covid_sunday_cumulative(just_data)
with_labels = hcat(labels, sunday_cumulative)
return states_covid_weekly(with_labels)
end
"""input 2020-02-02_sum
output 02-02"""
function shorten_date_label(aString)
return aString[6:10]
end
function states_covid_weekly(weekly_data)
grouped = DataFrames.groupby(weekly_data,[:State])
states_sumed = combine(grouped, names(grouped)[5:end].=> [sum])
state_labels = states_sumed[:,1]
dates_shortened = rename!(shorten_date_label, states_sumed[:,2:end])
hcat(DataFrame(State = state_labels),dates_shortened)
end
""" select state from DF """
function state_data(state_Abriv, states_weekly)
return states_weekly[states_weekly.State .== state_Abriv,:]
end
county_data(state_Abriv, county, county_weekly_covid) = @as data county_weekly_covid begin
data[data.State .== state_Abriv ,:]
data[data.County .== county, :]
end
country_covid_weekly(weekly_data) = @as data weekly_data begin
usa_covid_just_data(data)
combine(data, names(data).=> [sum])
rename(shorten_date_label, data)
end
plot_covid(coviddf) = plot_covid(coviddf, "New Cases Per Week")
function plot_covid(coviddf, title)
plot(coviddf[!,2],xticks = (1:8:nrow(coviddf), coviddf[!,1][1:8:end]),legend=false, title="New Cases Per Week: " * title, ylabel = "Number of New Cases", xlabel = "Week", formatter = :plain, dpi = 110, guidefontsize = 7, titlefontsize = 7, tickfontsize = 5)
end
plot_country(county_weekly_covid) = @as data county_weekly_covid begin
country_covid_weekly(data)
stack(data, 1:ncol(data))
plot_covid(data, "USA")
end
plot_state(state, states_weekly) = @as data states_weekly begin
state_data(state, data)
data[:,2:end] #Remove state column
stack(data, 1:ncol(data))
plot_covid(data, state)
end
plot_county(state, county, county_weekly_covid) = @as data county_weekly_covid begin
county_data(state, county, data)
data[:,5:end] #Remove state column
rename(shorten_date_label, data)
stack(data, 1:ncol(data)) #convert columns to rows
plot_covid(data, county)
end
function plot_two_states(stateA, StateB, states_new_weekly_covid)
a = plot_state(stateA, states_new_weekly_covid)
b = plot_state(StateB, states_new_weekly_covid)
plot(a, b, layout = (2), size = (700, 300), dpi = 90, guidefontsize = 6, titlefontsize = 6, tickfontsize = 5)
end
plot_two_states (generic function with 1 method)
covid_cases_url = "https://usafactsstatic.blob.core.windows.net/public/data/covid-19/covid_confirmed_usafacts.csv"
covid_cases_url = "https://static.usafacts.org/public/data/covid-19/covid_confirmed_usafacts.csv"
download(covid_cases_url,"currentCovid.csv")
covid_raw = DataFrame(CSV.File("currentCovid.csv"))
county_new_weekly_covid = counties_covid_weekly(covid_raw)
states_new_weekly_covid = states_covid_weekly(county_new_weekly_covid)
covid_raw[1:5,end-5:end]
5 rows × 6 columns
2022-11-16 | 2022-11-17 | 2022-11-18 | 2022-11-19 | 2022-11-20 | 2022-11-21 | |
---|---|---|---|---|---|---|
Int64 | Int64 | Int64 | Int64 | Int64 | Int64 | |
1 | 0 | 0 | 0 | 0 | 0 | 0 |
2 | 18592 | 18592 | 18592 | 18592 | 18592 | 18592 |
3 | 66268 | 66268 | 66268 | 66268 | 66268 | 66268 |
4 | 6959 | 6959 | 6959 | 6959 | 6959 | 6959 |
5 | 7612 | 7612 | 7612 | 7612 | 7612 | 7612 |